Claude/arax status code propagation ivt3l0 - #152
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.