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

http_status() should expose more content #618

Closed
jennybc opened this issue Oct 3, 2019 · 2 comments
Closed

http_status() should expose more content #618

jennybc opened this issue Oct 3, 2019 · 2 comments
Labels
feature a feature request or enhancement robustness ⛑️

Comments

@jennybc
Copy link
Member

jennybc commented Oct 3, 2019

http_status() is used when we turn a response into a warning or error. But it fails to reveal everything contained in the response about what went wrong.

Recent example encountered in gargle: r-lib/gargle#111

The problem ended up being that auth was initiated from a Docker container whose system time was 2 days out of sync! And this error was actually detailed in a response during the failure to get an access token via init_oauth_service_account(). Using debug() to inspect the response revealed this explanation:

content(res, "text")
# "{\n  \"error\": \"invalid_grant\",\n  \"error_description\": \"Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems.\"\n}"

but these details are not being surfaced by http_condition() and, therefore, stop_for_status().

@hadley hadley added feature a feature request or enhancement robustness ⛑️ labels Apr 3, 2020
@rbrown789
Copy link

Another example of this. I've been using httr to access the Auth0 Management API in a shiny app. Whenever an API call returns an error, the error details are contained in the "message" field of the JSON response (example for creating a user with a username that's too long):

content(resp,"text") 
# "{\"statusCode\":400,\"error\":\"Bad Request\",\"message\":\"Username should have between 1 and 15 characters.\",\"errorCode\":\"auth0_idp_error\"}"

But http_status() only returns the following:

http_status(resp)
# $category
# [1] "Client error"
# 
# $reason
# [1] "Bad Request"
# 
# $message
# [1] "Client error: (400) Bad Request"

@hadley
Copy link
Member

hadley commented Oct 31, 2023

httr has been superseded in favour of httr2, so is no longer under active development. If this problem is still important to you in httr2, I'd suggest filing an issue offer there 😄. Thanks for using httr!

@hadley hadley closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement robustness ⛑️
Projects
None yet
Development

No branches or pull requests

3 participants