sciencehistory / scihist_digicoll

Science History Institute Digital Collections
Other
11 stars 0 forks source link

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

Open honeybadger[bot] opened 2 months ago

honeybadger[bot] commented 2 months ago

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

jrochkind commented 2 months ago

"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 commented 2 months ago

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

eddierubeiz commented 2 months ago

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)