Skip to content

Permission denied error could be handled better #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Naktibalda opened this issue Apr 26, 2017 · 2 comments
Closed

Permission denied error could be handled better #47

Naktibalda opened this issue Apr 26, 2017 · 2 comments

Comments

@Naktibalda
Copy link
Contributor

Vault returns status 400 with body {"errors":["permission denied"]} if access token is incorrect or has insufficient permissions.

On receiving such status, vault-java-driver throws com.bettercloud.vault.VaultException: Expecting HTTP status 204 or 200, but instead receiving 400.
Which is very confusing, because Vault documentation says that it means 400 - Invalid request, missing or invalid data. See the "validation" section for more details on the error response.
And it doesn't provide any more details.

vault-java-driver makes it hard to debug by not exposing response body.
I think that vault-java-driver should incorporate contents of errors field in exception message.

@Naktibalda
Copy link
Contributor Author

Fun fact - it probably isn't a permission issue.
My token works in the REST client, but when I use it with BetterCloud vault-java-driver, I get status 400.
I tried debugging it and evaluated expression in this line: https://github.com/BetterCloud/vault-java-driver/blob/master/src/main/java/com/bettercloud/vault/api/Logical.java#L129

final int restStatus = restResponse.getStatus();

Expression new String(restResponse.getBody(), "UTF-8") returns empty string.

@Naktibalda
Copy link
Contributor Author

I apologize for spamming.

I made an identical request using invalid token and received {"errors":["permission denied"]} in REST client, but vault-driver still shows that response body is empty so it is impossible to debug it.

jentfoo pushed a commit to jentfoo/vault-java-driver that referenced this issue Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant