Repository navigation
fix(grok): preserve upstream media error messages and codes - #8669
Merged
Merged
Conversation
|
多久合并bro,坐等 |
Contributor
Author
|
@cshxql 修复和功能测试已完成,目前还不能给出合并时间,需要维护者审阅。当前 共享工具链升级在 #8670,该 PR 的安全检查已通过,但尚未合入;合入后我会同步这条 PR 并复核安全检查。以上为 AI agent 核对的当前状态。 |
extractUpstreamErrorMessage and extractUpstreamErrorCode drive failover,
model-not-found cooldown and account-disable decisions on every platform.
Reading a top-level code there short-circuited the OpenAI-compatible
model-not-found failover for vLLM-style bodies such as
{"object":"error","message":"model not found","code":400}. It also
added top-level token_revoked as a new disable path.
Restore the shared helpers to main. Add Grok-only grokUpstreamErrorMessage
and grokUpstreamErrorCode for the media error path, the content-policy
message and the error passthrough rule, so the Grok media fix in this PR
is unchanged. Adds tests that the shared extractors ignore the xAI flat
shape and that model-not-found still fails over with a top-level code.
Owner
|
维护者复核后已直接在本分支调整,并合入最新 main:
Maintainer adjusted this PR and merged the latest main. The shared extractors drive failover, model-not-found cooldown and account-disable decisions on every platform. Reading a top-level |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Refs #8666
CI 跟进(2026-11-11):当前 head
c8f4264f8的功能测试、lint 等检查已成功,backend-security命中当前 Go 1.27.3 基线的 GO-2026-6859。共享工具链升级已独立提交到 #8670;该 PR 精确 head267e2a954的 backend-security 已成功。本 PR 的安全失败仍需共享升级合入后同步基线并复核,当前 head 保持本次 Grok 字段修复范围。xAI 返回
{"code":"invalid_image","error":"Image could not be decoded."}时,Grok 图片链路会把具体原因替换成xAI upstream returned status 400,媒体错误包装也会丢失已有的上游错误码。此改动补上顶层字符串error和标量code的解析回退,并把错误码带入媒体错误对象。异步图片任务复用该对象,轮询结果也保留具体消息和错误码。既有嵌套错误、
detail、message的解析优先级保持一致;内容拒绝、账号错误码过滤、管理员错误改写和可重试错误的账号切换仍沿用原策略。媒体错误序列化统一对消息及错误码执行现有敏感查询参数脱敏,未知错误对象继续使用通用兜底。本 PR 处理 #8666 中的结构化消息/错误码缺口。验证使用 Go 1.27.3(macOS arm64):
main:15 个失败,22 个兼容与策略对照通过;补充管理员消息透传的脱敏用例后,最终 38 个叶子场景全部通过。/v1/images/edits以及异步提交、失败保存和任务轮询,并断言确定性 400 只有一次上游调用、敏感查询参数被脱敏。go test -p=2 -tags=unit ./... -json:26,922 通过,41 条件跳过。go test -p=2 -tags=integration ./... -json:16,169 通过,16 条件跳过。golangci-lint v2.14.0:golangci-lint run --timeout=30m ./...,0 issues;git diff --check通过。使用合成上游响应,未调用真实 xAI 或验收线上部署。实现与本地验证由 AI 完成。