Repository navigation
fix(providers): surface errors sent mid-stream by OpenAI-compatible and Codex APIs - #1702
Open
pcbeingused33 wants to merge 1 commit into
Open
pcbeingused33 wants to merge 1 commit into
pcbeingused33 wants to merge 1 commit into
Conversation
clark-cant
reviewed
Nov 26, 2026
clark-cant
left a comment
Contributor
There was a problem hiding this comment.
Summary: Fixes a real correctness gap: once an OpenAI-compatible or Codex stream has started (HTTP 200), upstream failures arrive as an in-band error payload, which both providers previously ignored, returning the partial or empty reply as success. Adds a shared streamErrorMessage helper, an Error field on openAIStreamChunk, an error case in the Codex SSE handler, and tests.
Risk level: Low
Mandatory gates
- Duplicate / prior implementation: clear. No prior
streamErrorMessagehelper ondev; PR #1701 (same author) targets a different concern (no Ollama replay after emit); the Anthropic provider already returns an error on in-banderrorevents (anthropic_stream.go), which this PR mirrors. - Project standards: docs found (AGENTS.md / CLAUDE.md / CONTRIBUTING.md); the change is idiomatic Go and follows existing provider patterns.
- Strategic necessity: clear value. Silent success on an upstream error is a correctness bug; the fix is small, well-scoped, and covered by tests.
Findings
- Critical: none.
- Important: none.
- Suggestion: in the Codex
errorcase, the final fallbackmsg = string(event.Code)yields the raw JSON token (for example"server_error"with quotes) when botherrorandmessageare empty. Cosmetic only.
Verdict: Approve. No critical or important issues; CI green (go / release-versioning / web) and mergeState CLEAN. Merge left to a maintainer approval.
Posted by /ck:review-pr at 2026-11-26T16:09:19Z
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Once a stream has started the HTTP status is already 200, so upstream failures arrive as an error payload inside the SSE stream. The OpenAI-compatible and Codex providers ignored it and returned the partial (or empty) reply as a success; they now return an error, as the Anthropic provider already does.
Root cause:
openAIStreamChunkhad noerrorfield, so{"error":{...}}chunks (object or string) were parsed as empty chunks.processSSEEventhandledresponse.failedbut not theerrorevent."error": nulland empty values are ignored, so gateways that always send the field are unaffected.Type
Target Branch
devChecklist
go build ./...passesgo build -tags sqliteonly ./...passesgo vetpasses (./internal/providers/...)go test -race ./internal/providers/...(providers packages only)Test Plan
New tests in
openai_stream_error_test.gostream a partial reply followed by an error from a local SSE server. The OpenAI (three payload shapes) and Codex (flat and nested) cases fail without the change and pass with it; a"error": nullchunk still succeeds.🤖 Generated with Claude Code