fix: strip unsupported OpenAI passthrough fields#1656
Open
gebdalaoli-arch wants to merge 3 commits intoWei-Shaw:mainfrom
Open
fix: strip unsupported OpenAI passthrough fields#1656gebdalaoli-arch wants to merge 3 commits intoWei-Shaw:mainfrom
gebdalaoli-arch wants to merge 3 commits intoWei-Shaw:mainfrom
Conversation
(cherry picked from commit 7855399eefebeb7f9333658e01e3b373b64ffb86)
Author
|
补充说明一下这个 bug 的实际影响: 如果这里不把 我继续检查了当前
所以,这个 PR 对 bug 根因和用户侧表现的判断是对的,但从当前主线状态看,这个缺口大概率已经被更上游、更通用的一层修掉了。如果维护者最后不合并这个 PR,比较可能的原因是“主线已有覆盖”,而不是这个问题本身不存在。 |
Author
|
这次我把分支先同步到了最新 这次提交做了三件事:
这样做的原因是:最新 现在三条路径共用同一份字段定义,后续如果再新增同类 unsupported Responses 字段,只需要改一处列表,不会再出现 passthrough、official client、generic filter 各修一半的情况。 已验证:
|
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.
概要
openAIResponsesUnsupportedFields列表,统一定义prompt_cache_retention和safety_identifierapplyCodexOAuthTransform(...)、以及通用请求体过滤三条路径复用同一份规则问题说明
这个问题本质上不是“少删了一个字段”这么简单,而是同一类 unsupported Responses 字段在不同路径上的过滤规则已经分叉了:
openai_passthrough的 OAuth / compact 路径走normalizeOpenAIPassthroughOAuthBody(...)applyCodexOAuthTransform(...)openai_gateway_service.go里还有一层兜底在最新
main上,通用层已经会过滤prompt_cache_retention和safety_identifier,但它只在!isCodexCLI条件下执行;而applyCodexOAuthTransform(...)之前只剥prompt_cache_retention,没有等价剥离safety_identifier。结果就是:同类字段在三条路径上的处理不一致,官方客户端 / compact / OAuth 场景仍然容易出现漏网。用户侧表现
当 compact / 自动压缩上下文请求把这些字段原样带到上游时,ChatGPT internal Codex endpoint 会返回
400 Unsupported parameter一类错误,网关侧通常表现为502。这会导致:修复方式
这次不是继续在某一条路径上“补一个 if”,而是把同一类字段过滤收敛到共享列表:
openAIResponsesUnsupportedFieldsnormalizeOpenAIPassthroughOAuthBody(...)使用该共享列表,保证 passthrough / compact 路径一致applyCodexOAuthTransform(...)也使用该共享列表,补上官方客户端 OAuth transform 对safety_identifier的缺口验证
go test ./internal/service -run 'OpenAIGatewayService_OAuthPassthrough|ApplyCodexOAuthTransform' -count=1