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

Better recovery from JSON::ParserError when Getty site returns HTML instead of JSON #2674

Open
honeybadger bot opened this issue Jul 15, 2024 · 3 comments

Comments

@honeybadger
Copy link

honeybadger bot commented Jul 15, 2024

The genre dropdown in the work metadata makes an API call to Getty's art and architecture thesaurus (AAT) via QuestioningAuthority.

If the Getty site is down, it returns HTML instead of JSON, namely:

<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>

This in turn triggers a JSON::ParserError at
/gems/qa-5.11.0/lib/qa/authorities/getty/aat.rb:6

No error is displayed to the user.

View full backtrace and more info at honeybadger.io

@eddierubeiz eddierubeiz changed the title [scihist_digicoll/production] JSON::ParserError: unexpected token at '<html> <head><title>503 Service Temporarily Unavailable</title></head> <body> <center><h1>503 Service Temporarily Unavailable</h1></center> <hr><center>nginx</center> </body> </html> ' Better recovery from JSON::ParserError when Getty site returns HTML instead of JSON Jul 15, 2024
@jrochkind
Copy link
Contributor

"No error is displayed to the user" --> What does happen? Just a "no results" message? That does seem not great.

Things to look at and then consider:

Are no error conditions ever displayed to the user by our drop-down front-ends, or just this error condition doesn't trigger errors?

I think probably we need an "error happened" message (?), but not sure if the specific technical error needs to be displayed to user? Either way, Rails logs and ideally (if easy) Javascript console should show specific error message of some kind -- although the parse error could be enough?

@eddierubeiz
Copy link
Contributor

I think from the user's standpoint, not much happens-- you just get an empty list of suggestions in the dropdown.

@eddierubeiz
Copy link
Contributor

You won't be able to reproduce this any more -- the service is back up.
Just ran a search for cardboard in dev; the normal dev log will be helpful in fixing this, if we decide to.

Started GET "/authorities/search/getty/aat?q=Cardboard" for ::1 at 2024-07-16 09:14:59 -0400

[...]

Processing by Qa::TermsController#search as TEXT
  Parameters: {"q"=>"Cardboard", "vocab"=>"getty", "subauthority"=>"aat"}

Retrieving json for url: http://vocab.getty.edu/sparql.json?query=SELECT%20%3Fs%20%3Fname%20%7B%20%3Fs%20a%20skos%3AConcept%3B%20luc%3Aterm%20%22Cardboard%22%3B%20skos%3AinScheme%20%3Chttp%3A%2F%2Fvocab.getty.edu%2Faat%2F%3E%20%3B%20gvp%3AprefLabelGVP%20%5Bskosxl%3AliteralForm%20%3Fname%5D.%20FILTER%20regex%28%3Fname%2C%20%22Cardboard%22%2C%20%22i%22%29%20.%20%7D%20ORDER%20BY%20%3Fname&_implicit=false&implicit=true&_equivalent=false&_form=%2Fsparql

Completed 200 OK in 344ms (Views: 0.4ms | ActiveRecord: 0.0ms | Allocations: 1357)

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