Skip to content

Re-land #8299 (draft: blocked by review) - #8415

Draft
lidge-jun wants to merge 1 commit into
devfrom
reland/pr-8299
Draft

lidge-jun wants to merge 1 commit into
devfrom
reland/pr-8299

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Re-land of #8299, held as a draft. It was reverted in #8402, and its post-merge independent review FAILED: a P1 finding plus three P2s (details kept private; owned by the new-contributor merge lane). Do not merge it until the blocker is fixed with a failing-first test and a fresh independent review (and separate security review where applicable) passes.

Verification

  • Cherry-picked unchanged onto current dev.
  • NOT RUN: CI on this head. The fix has not been made yet.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

…8299)

* fix(relay): report an untyped SSE error envelope as response.failed

Some OpenAI-compatible gateways end a stream with an SSE data frame that
is only `{"error":{...}}`, with no root `type`, followed by `[DONE]` and
EOF. Both bare-error recognizers in src/server/relay.ts required a root
`type: "error"`, so the frame was ignored and EOF synthesized
`response.incomplete` with `adapter_eof`, dropping the diagnostic.

Accept a frame with no root `type` that carries an `error` object in
both `boundedBareUpstreamErrorMessage` (tee inspection) and
`boundedBareUpstreamError` (client relay, tee and eager). A typed event
of any other kind is still never treated as a bare error. Redaction,
message bounds, class/code mapping and terminal precedence are unchanged.

The combo preflight is left as is: it treats the untyped frame as a
non-control event and commits the target, so it never resends it; the
relay now reports the failure. A test pins that boundary.

Closes #8216

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(relay): finish untyped error envelope handling across readers

- Treat an untyped {"error":{...}} cyber_policy refusal as the policy
  terminal in both rewrite selection and terminal detection, like the
  typed error event, so later bytes are dropped.
- Tee inspection uses the same structured extraction as the client
  boundary, so a refusal code without a message reports failed.
- A code or error class without a message keeps a bounded fallback
  diagnostic and ends in response.failed instead of adapter_eof.
- The SSE-to-WebSocket pump skips the untyped envelope instead of
  failing it as invalid JSON, so the boundary's terminal reaches WS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Ingwannu <ingwannu@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9aeffab)
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the bug Something isn't working label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants