Skip to content

Surface the request id when a run fails - #14

Merged
kev1n merged 1 commit into
mainfrom
surface-request-id-on-failure
Aug 27, 2026
Merged

Surface the request id when a run fails#14
kev1n merged 1 commit into
mainfrom
surface-request-id-on-failure

Conversation

@kev1n

@kev1n kev1n commented Aug 27, 2026

Copy link
Copy Markdown
Member

Every /v1/run response has always carried X-Anyapi-Request-Id, including failures. This client
read only the JSON body and printed error.message, so a failed run printed a bare
all providers failed with no handle on it.

On 2026-08-26 a customer filed five bug reports through anyapi report-bug. Four said "no result
file or request id was produced", and each had to be traced back to a stored request from a
customer id and a timestamp. The id was on the wire the whole time.

What changed

  • ApiError carries requestId, read from the response header in requestJson.
  • The message renders as all providers failed (request 0a508adc-...); unchanged when the response
    carries no id, so non-run routes look exactly as before.
  • REQUEST_ID_HEADER in constants.ts so the header name has one owner.
  • skills/anyapi-run/SKILL.md now says where to find the id on a FAILED run. That is the gap that
    produced the empty reports: it told an agent to pass --request-id without saying where to get
    one when the run never returned a result.

Tests

__tests__/run.test.ts gains two cases, proven to fail without the fix (reverting src/ leaves
Tests 1 failed | 97 passed):

  • a 502 carrying the header renders the id into the thrown message
  • a 401 carrying no header leaves the message untouched

npm test 98 passed, npm run build clean.

Ecosystem

The gateway half shipped in getanyapi-com/anyapi#807, which also adds requestId to the error
body. This reads the header instead, so it works against any gateway version and does not depend
on that deploy. No discovery contract, command name, option, or output shape changed, so the
handwritten discovery reader and the other bundled skills are untouched.

Version bumped to 0.8.1; tag after merge to publish.

🤖 Generated with Claude Code

Every /v1/run response has always carried X-Anyapi-Request-Id, including
failures, but this client read only the JSON body and printed
error.message. So `anyapi run` on a failed call printed a bare
"all providers failed" with no handle on it.

On 2026-08-26 a customer filed five bug reports through `anyapi
report-bug`; four of them said "no result file or request id was
produced", and each had to be traced back to a stored request from a
customer id and a timestamp. The id was on the wire the whole time.

ApiError now carries it and renders `all providers failed (request <id>)`.
The anyapi-run skill says where to find it on a FAILED run, which is the
gap that produced the empty reports: it already told an agent to pass
--request-id without saying where to get one when the run never returned
a result.

The gateway half shipped in getanyapi-com/anyapi#807, which also adds
requestId to the error body. This reads the header instead, so it works
against any gateway version.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kev1n
kev1n merged commit e54e5d6 into main Aug 27, 2026
2 checks passed
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