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

Make HTTP errors great again #92

Open
florianm opened this issue Jun 19, 2017 · 3 comments
Open

Make HTTP errors great again #92

florianm opened this issue Jun 19, 2017 · 3 comments

Comments

@florianm
Copy link
Contributor

Example: authentication error on package_show expects JSON by default, but chokes on the HTTP page with the error message:

Error: lexical error: invalid char in json text. <!DOCTYPE HTML PUBLIC "-//W3C// (right here) ------^
11. parse_string(txt, bigint_as_char)
10. parseJSON(txt, bigint_as_char)
9. fromJSON_string(txt = txt, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, flatten = flatten, ...)
8. jsonlite::fromJSON(x, FALSE)
7. jsl(res)
6. structure(x, class = class)
5. as_ck(jsl(res), "ckan_package")
4. get_package(x, ...)
3. as.ckan_package.character(id, url = url)
2. as.ckan_package(id, url = url)
1. ckanr::package_show("MY_CKAN_DATASET_ID")

Would it be worth the effort to catch HTTP errors e.g. somewhere here?

@sckott
Copy link
Contributor

sckott commented Jun 20, 2017

yeah! will have a look

@florianm
Copy link
Contributor Author

florianm commented Jun 22, 2017

My example shows ckanr bumping into a federated login, which re-directs the API call to the login page (and returns HTTP status 200).

As "200" is no error code, ckanr doesn't pick this up as a problem - we'd need to test for "is this valid HTTP response an API response".

It's definitely a silly thing on our end (shouldn't our HTTP status be in the "redirected" 300 range?), but the error message I got was confusing at first.

@sckott
Copy link
Contributor

sckott commented Jun 22, 2017

can you do the same request with config = httr::verbose() passed in to the fxn call - curious to see what headers and such look like

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

2 participants