d devhelper

← All errors

Data problem

OAuth2::Error

{"detailedmessage":"You do not have access to this context.","name":"ContextAccessError"}

FetchAthenaReferralsJob@athena_referrals144 events · 0 users first seen 231 d agolast seen 26 min ago

In one line

Athena rejects one or more enabled AthenaContexts with "You do not have access to this context". The job catches the error, logs it and reports it to Bugsnag on purpose, so nothing is crashing.

Checked against the code

What happened

  • FetchAthenaReferralsJob loops over every enabled AthenaContext and calls Athena's signed-off orders endpoint for each.
  • Athena returns ContextAccessError for at least one practice, so the API credentials have no access to that context.
  • The job rescues OAuth2::Error, writes an ErrorLog row and calls Bugsnag.notify(e) (line 71). It then carries on with the next context.
  • There are 433 events over 231 days, roughly 2 a day. That fits a few contexts failing on every scheduled run, not a one-off. It is not a deploy side effect.

What to do next

  1. Query Shows which practice ids Athena is refusing; expect a few, not all of them. I did not check the error_logs column names against db/schema.rb.
    SELECT error_log_data->>'practice_id' AS practice_id, COUNT(*) AS n, MAX(created_at) AS last_seen FROM error_logs WHERE error_log_type = 'FetchAthenaReferralsJob' AND error_log_data->>'error_message' LIKE '%ContextAccessError%' GROUP BY 1 ORDER BY n DESC;
  2. Check For each failing practice, check in Athena whether the API app still has access to that context. If the practice has left or revoked access, disable its AthenaContext so the job stops calling it.

Queries are shown, never run. Check them before using them on production.

Ask a follow-up

Continues the same session, so it still remembers the error and the code it read.

Enter to send · Shift+Enter for a new line
Analysed 1 h ago · claude-sonnet-5-5 · $0.05