elastic / elastic/elastic-agent

Misleading error being reported when enrolling an agent with wrong or invalid token

Open
#759 3 comments 0 reactions 0 assignees View on GitHub
8.7-candidate bug Team:Elastic-Agent-Control-Plane
Dominant language
Go
Stars
275
Forks
264
Avg merge
1d 20h
Merged PRs (30d)
298

Description

When trying to enrol an agent with the wrong/invalid token, the error message in the console is:
```
"Error: fail to enroll: fail to execute request to fleet-server: status code: 400, fleet-server returned an error: BadRequest"
```

When looking into the Fleet server, the real error (a 401 Unauthorized) is there, but reported with a 400 status:
```
"apikey auth response AbCdEfG1234567890HiJ: [401 Unauthorized] {\"error\":{\"root_cause\":[{\"type\":\"security_exception\",\"reason\":\"unable to authenticate with provided credentials and anonymous access is not allowed for this request\",\"additional_unsuccessful_credentials\":\"API key: unable to find apikey with id AbCdEfG1234567890HiJ\",\"header\":{\"WWW-Authenticate\":[\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\",\"Bearer realm=\\\"security\\\"\",\"ApiKey\"]}}],\"type\":\"security_exception\",\"reason\":\"unable to authenticate with provided credentials and anonymous access is not allowed for this request\",\"additional_unsuccessful_credentials\":\"API key: unable to find apikey with id AbCdEfG1234567890HiJ\",\"header\":{\"WWW-Authenticate\":[\"Basic realm=\\\"security\\\" charset=\\\"UTF-8\\\"\",\"Bearer realm=\\\"security\\\"\",\"ApiKey\"]}},\"status\":401}"
```

For confirmed bugs, please report:
- Version: 7.17.1
- Operating System: Linux
- Steps to Reproduce:
* Spin a Fleet server
* Enrol agent with a wrong token
* Compare message on console with error in the logs

@cmacknz as discussed. Thanks a lot! :-)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.