try to recover from failure seen in production#107
try to recover from failure seen in production#107marcmengel wants to merge 1 commit intodevelopfrom
Conversation
goodenou
left a comment
There was a problem hiding this comment.
Hi Marc. What do you think about expanding this a bit.
`try:
jobs_results.raise_for_status()
except requests.exceptions.HTTPError:
record_queue_log(
f"Ferry request HTTP {jobs_results.status_code}: {jobs_results.text}"
)
jobs_results.close()
return None
try:
jobs_dict = jobs_results.json()
except (requests.exceptions.JSONDecodeError, ValueError):
record_queue_log(
f"Ferry request returned non-JSON (HTTP {jobs_results.status_code}): {jobs_results.text}"
)
jobs_results.close()
return None
finally:
jobs_results.close()
if jobs_dict.get("errors") is not None:
record_queue_log(f"Ferry request yielded some errors: {jobs_dict.get('errors')}")
if not jobs_dict.get("data"):
record_queue_log("Ferry request yielded no results (valid JSON, empty data)")
return None`
The raise_for_status section catches upstream query errors, and we now log whether there was an error or just no data.
Tired of seeing the stack traces for this in production...