fix(resilience): surface Responses failed.error.message in 502s - #12472
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, includes a targeted unit test, and preserves existing failure classification behavior while improving error visibility.
Pull request overview
Improves non-streaming /v1/responses malformed-response diagnostics by surfacing a provider-supplied response.error.message (sanitized) when status="failed", instead of always using the generic fallback string. This aligns the 502 body with the upstream error already preserved by the translator, while keeping the existing request-scoped upstream_response_failed classification.
Changes:
- Update
describeMalformedNonStream()to includeresponse.error.message(trimmed; fallback unchanged when missing/empty). - Add a unit test asserting the upstream error message is surfaced for failed Responses bodies.
Commands run: Not run in this review (please run npm run test:coverage).
Changed test files: tests/unit/diagnostics.test.ts
Coverage (custom): Not verified in this review (must meet 60/60/60/60 via npm run test:coverage).
File summaries
| File | Description |
|---|---|
| open-sse/utils/diagnostics.ts | Use response.error.message (when present) in the failed-Responses diagnostic message while preserving existing classification fields. |
| tests/unit/diagnostics.test.ts | Add regression coverage ensuring failed Responses bodies surface the upstream error message. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Return trimmed upstream message from describeMalformedNonStream and leave sanitization to buildErrorBody for a single sanitization pass. Signed-off-by: Ravi Tharuma <RaviTharuma@users.noreply.github.com>
77b1a61 to
d3f3764
Compare
bb8e75a
into
diegosouzapw:release/v3.8.51
Fixes #12136.
describeMalformedNonStream treated every Responses status=failed body as the generic "upstream reported a failed response without usable output" string, even when openai-responses.ts already stored the real upstream error at response.error.
This keeps the request-scoped upstream_response_failed code (combo skip / exhaustion unchanged) and interpolates a sanitized error.message when present. Empty/missing error still uses the generic fallback.
The 3.8.49 vs 3.8.50 producer regression remains a separate follow-up; this only stops the classifier from discarding the error the translator already holds.