Skip to content

fix(ai-gateway): standardize stream error payloads - #4928

Merged
chrarnoldus merged 2 commits into
mainfrom
fix/standardize-stream-error-payloads
Jul 31, 2026
Merged

fix(ai-gateway): standardize stream error payloads#4928
chrarnoldus merged 2 commits into
mainfrom
fix/standardize-stream-error-payloads

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • remove the non-standard vercel_request_id property from JSON response-read errors
  • remove the same property from Chat Completions, Messages, and Responses SSE error objects
  • retain the request ID suffix in each human-readable error message and retain internal request-ID logging
  • update focused assertions to require that streamed error objects omit the custom field

Compatibility

Vercel AI SDK v6 parses protocol-native error shapes:

  • OpenAI-compatible errors use error.message with optional type, param, and code
  • Anthropic Messages error events use error.type and error.message
  • OpenAI Responses error events use their standard type, code, and message fields

The custom vercel_request_id member is unnecessary for correlation because the same value remains embedded in message, and omitting it keeps the emitted objects within those protocol shapes.

Reference: https://github.com/vercel/ai/tree/release-v6.0

Verification

  • pnpm --filter web exec jest --runInBand --forceExit src/lib/rewriteModelResponse.test.ts (72 tests passed)
  • pnpm exec oxfmt --list-different apps/web/src/lib/rewriteModelResponse.ts apps/web/src/lib/rewriteModelResponse.test.ts
  • git diff --check

@chrarnoldus chrarnoldus self-assigned this Jul 31, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

High confidence: the diff is a pure removal of the non-standard vercel_request_id member from the JSON read-error body and from the Chat Completions, Messages, and Responses SSE error objects, with request-ID correlation preserved in every message string and in internal errorExceptInTest/logExceptInTest logging, and no remaining references to the dropped ResponseReadError.vercelRequestId field.

Files Reviewed (2 files)
  • apps/web/src/lib/rewriteModelResponse.ts
  • apps/web/src/lib/rewriteModelResponse.test.ts
Notes (out of diff scope)
  • apps/web/src/lib/ai-gateway/providers/upstream-request.ts:161 and :185 still emit vercel_request_id for pre-response failures (client disconnect / upstream fetch failure), so the field remains part of the gateway's error surface for those paths. Not changed by this PR; flagged only as a consistency follow-up if full standardization is the goal.

Reviewed by claude-opus-5 · Input: 24 · Output: 6K · Cached: 530.2K

Review guidance: REVIEW.md from base branch main

@chrarnoldus
chrarnoldus merged commit a5f6ad4 into main Jul 31, 2026
15 checks passed
@chrarnoldus
chrarnoldus deleted the fix/standardize-stream-error-payloads branch July 31, 2026 14:45
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.

2 participants