fix: Chat/Messages 非流式错误响应透传上游错误详情#629
Open
fengshao1227 wants to merge 1 commit into
Open
Conversation
…responses The conversation (Chat/Messages) non-streaming branch unconditionally fed all response bodies through ConvertResponseJSONWithOptions, including non-2xx error responses. When the upstream returned a non-standard error format (HTML, plain text, or non-Responses-API JSON), the conversion failed and the original error details — rate limit info, auth failure messages, quota errors — were swallowed. Now: attempt conversion first (upstream may return a standard Responses API error), and if conversion fails on a non-2xx response, fall back to passing through the original body unchanged. This matches the Responses path (line 134) which already guards on 2xx. Closes chenyme#628
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
Closes #628
Chat/Messages 非流式分支(
adapter.go:162)无条件将所有响应体通过ConvertResponseJSONWithOptions转换,包括非 2xx 错误响应。当上游返回非标准格式的错误(HTML、纯文本、非 Responses API JSON)时,转换失败导致原始错误信息丢失。影响:所有通过
/v1/chat/completions或/v1/messages以stream: false调用的用户,在遇到 429(限流)、401(认证失败)、500(上游错误)等情况时,收不到有意义的错误信息。Root Cause
Responses 路径(第 134 行)和流式路径(第 158 行)都有
resp.StatusCode >= 200 && resp.StatusCode < 300守卫,但非流式else分支没有。Fix
Test plan
go build ./...编译通过go test ./...全量通过(57 包,0 失败)