Skip to content

Claude/arax status code propagation ivt3l0 - #152

Merged
maximusunc merged 4 commits into
mainfrom
claude/arax-status-code-propagation-ivt3l0
Sep 2, 2026
Merged

Claude/arax status code propagation ivt3l0#152
maximusunc merged 4 commits into
mainfrom
claude/arax-status-code-propagation-ivt3l0

Conversation

@maximusunc

Copy link
Copy Markdown
Collaborator

No description provided.

maximusunc and others added 4 commits September 1, 2026 21:34
…status

Propagating the HTTP status code was not enough: ARAX answers HTTP 200 for
most of its own failures and reports them in the TRAPI status field, so a
service having internal issues still looked completely healthy to a check
of the HTTP code alone, and the query completed OK.

The ARAX worker now validates the body of a 2xx as well as its code. A body
that isn't a TRAPI response (an error envelope from ARAX or from something
in front of it) and a TRAPI status that names an error or a failure both
raise ARAXServiceError, which puts ARAX's status on the span as
arax.trapi_status, in the query's logs, and marks the query ERROR. Statuses
that describe a non-failure outcome are left alone, so a query ARAX
answered fine is not failed on an unrecognized status. When ARAX did send a
usable response its own body is what the caller gets back -- its status,
description and logs say more about the failure than anything synthesized.

Two places then reported that failure as success anyway:

- /asyncquery_status returned a hardcoded {"status": "Queued"} for every
  query it was ever asked about (a stub with a TODO), so a failed query and
  a healthy one were indistinguishable. It now reports Running, Completed
  or Failed from the query's own row, with the query's logs -- where the
  upstream status code is recorded -- instead of an empty list.
- The sync path returned the stored response with no hint that the query
  had finished with anything but OK; a response an operation never got to
  write looks exactly like one that legitimately found nothing. The stored
  status is now stamped onto the TRAPI response, leaving an error the ARA
  reported itself alone, since that one is more specific.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BmsMzWR6tNbDM2uSxh47n8
Treating a TRAPI status of "Error" inside an HTTP 200 as a failed query was
speculation about how ARAX reports its internal issues, and it isn't what
was hiding them: the sync path returned the stored response without ever
mentioning that the query had finished with anything but OK. That fix, and
the /asyncquery_status one alongside it, stay.

This restores the ARAX worker to propagating ARAX's HTTP status code, and
drops the body inspection, the TRAPI-status check and the response the
exception carried for it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BmsMzWR6tNbDM2uSxh47n8
The body has carried a TRAPI error status since apply_query_status went in,
but every answer /query gave was still HTTP 200, so a caller that checks
the status code rather than parsing the payload for a status field saw a
failed query as a successful one. All four ways a query can fail after
intake now answer 500: an operation that errored, a query that ran out of
budget or was abandoned, a response that isn't in the datastore (which had
no status code at all on its ORJSONResponse, so it defaulted to 200), and
the caller's own timeout elapsing with the query still in flight.

TRAPI 1.5 documents 200, 400, 429, 500 and 501 for this operation, so they
all report the spec's InternalServerError rather than a more precise code
the schema doesn't allow -- 504 for the two timeout cases. Which kind of
failure it was stays in the response's own status and description.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BmsMzWR6tNbDM2uSxh47n8
Reporting every post-intake failure as 500 kept /query inside the set of
codes TRAPI 1.5 documents, but it told the caller less than it knows. Each
way a query can fail now answers with the code that actually describes it:

- an operation that errored stays 500, a genuine internal error;
- a query that ran out of its budget (TIMEOUT), one reaped without ever
  completing (Abandoned: ...), and the caller's own timeout elapsing with
  the query still in flight are 504 -- Shepherd is fine, the work behind it
  didn't finish in time;
- a query that was never accepted because the datastore was unavailable is
  503, which says the retry its description asks for is worth making.

The mapping from a stored query status to its code lives in
query_status_code, so the two places that answer from a finished query's
row agree.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BmsMzWR6tNbDM2uSxh47n8
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.67%. Comparing base (58ae35f) to head (07f18b3).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Coverage Δ
shepherd_server/base_routes.py 80.17% <100.00%> (+17.34%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58ae35f...07f18b3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maximusunc
maximusunc merged commit 4bdc2f0 into main Sep 2, 2026
2 checks passed
@maximusunc
maximusunc deleted the claude/arax-status-code-propagation-ivt3l0 branch September 2, 2026 02:31
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

Successfully merging this pull request may close these issues.

1 participant