Repository navigation
feat(ai): put the provider error type and request id on RUN_ERROR - #1880
Conversation
Add toRunErrorDetails to read errorType and requestId from an SDK error. The Anthropic and openai-base text adapters spread them on RUN_ERROR, and chat() moves them to metadata.tanstack. code stays the HTTP status.
🦋 Changeset detectedLatest commit: 006d3dd The changes in this PR will be included in the next version bump. This PR includes changesets to release 52 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
View your CI Pipeline Execution ↗ for commit 006d3dd
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-cloudflare
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-compaction
@tanstack/ai-computer-local
@tanstack/ai-computer-playwright
@tanstack/ai-computer-sandbox
@tanstack/ai-computer-use
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-e2b
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-ollaya
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-reactor
@tanstack/ai-remix
@tanstack/ai-sandbox
@tanstack/ai-sandbox-blaxel
@tanstack/ai-sandbox-boxd
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-e2b
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-railway
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@tanstack/ai-solid
@tanstack/ai-svelte
@tanstack/ai-typesafe
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-worldlabs
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
Coverage✅ Coverage held across 70 compared package(s). Each package is measured twice in this job — on this PR and on its merge-base with
|
RUN_ERRORnow tells you which provider error happened and which request failed. An Anthropic 529 still hascode: '529', andmetadata.tanstacknow also haserrorType: 'overloaded_error'and the provider'srequestId. You can retry onoverloaded_errorwithout reading the message text, and you can give the request id to the provider's support.🎯 Changes
toRunErrorDetails(error)in@tanstack/ai/adapter-internals. It readserrorTypefrom the SDK error'stypeor the error body, andrequestIdfromrequestID,request_id, or therequest-id/x-request-idheader. Each value must be a string of 128 characters or fewer.chat()moves them tometadata.tanstackonRUN_ERROR.codedoes not change.toRunErrorPayloaddoes not change, because about 65 places spread its result.toRunErrorRawEventcomment no longer groups request ids with secrets. A request id is not a secret.docs/chat/stream-events.md,docs/protocol/metadata.md. Changeset:run-error-provider-details.This came from an app that builds on TanStack AI (item A15 on its findings list).
✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
Testing
Commands run. The new
packages/ai/tests/run-error-details.test.tsand the new cases in the Anthropic and openai-baseretry-after-wiretests pass. They use the real SDKs with a mockedfetch, and they fail without the change. The related adapter test files pass (224 tests).test:typesandtest:oxlintpass for the changed packages. Not run locally:pnpm test:pr, the full suites, and E2E. CI runs them.Manual test.
pnpm --dir packages/ai exec vitest run tests/run-error-details.test.ts.pnpm --dir packages/ai-anthropic exec vitest run tests/retry-after-wire.test.ts. The 529 case checkserrorType: 'overloaded_error'and the request id onRUN_ERROR.How this PR makes testing easy. The two test files above.
Risk / rollback
Low. Two optional fields are added, and nothing existing changes. To undo, revert the PR.
Public API change
Before
After
Summary by CodeRabbit