Skip to content
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

api: some api client library methods mask the underlying error when non-200 status codes are received #10865

Closed
dnephin opened this issue Aug 17, 2021 · 3 comments
Assignees
Labels
theme/api Relating to the HTTP API interface type/bug Feature does not function as expected

Comments

@dnephin
Copy link
Contributor

dnephin commented Aug 17, 2021

See #8816

Overview of the Issue

Copied from #8816

Consul agent returns errors in plain text. Yet when this happens the api client still tries to decode them in JSON, failing, and hiding the real error message.

It seems like some methods in the api client library do properly check the error code with requireOk, where as others do not. The methods that do not properly check the error code will error with JSON decode errors when the HTTP response was not 200. This error masks the real underlying problem, making the api client library difficult to use.

@acpana
Copy link
Contributor

acpana commented Sep 20, 2021

We merged #11054 to allow the error status code to be queried programmatically.

Keeping this issue open until I take a pass over all doRequest() func calls and make sure they're wrapped in requireHttpCodes() or return a StatusError type

@acpana
Copy link
Contributor

acpana commented Sep 29, 2021

@dnephin with PR #11158 I think we can close this issue. What do you think?

For the refactor discussed here #11158 (comment) I can open an issue to track visibility.

@dnephin
Copy link
Contributor Author

dnephin commented Sep 29, 2021

Sounds good!

@dnephin dnephin closed this as completed Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/api Relating to the HTTP API interface type/bug Feature does not function as expected
Projects
None yet
Development

No branches or pull requests

2 participants