Skip to content

[PR] fix: relay root JSON arrays without conversation preparation - #7028

Closed
Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_nonobject-conversation
Closed

Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_nonobject-conversation

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The conversation gate accepts any truthy JSON object, including arrays. Responses and Google endpoints consequently pass root arrays through object spreading and conversation preparation. With a session header, [1, {"field":"untouched"}] becomes an object with numeric keys; Google also adds conversation fields. Without a stable identity, the proxy can reject the non-conversation request locally instead of letting the upstream apply its contract.

Change

Exclude root arrays from the existing conversation gate so the existing raw-forward path relays them verbatim. This leaves nested input/contents arrays inside genuine object conversations eligible for preparation. It applies to proxy mode and the plugin-marked proxy path; native plugin-only injection is unchanged.

Verification

  • Base: 301e1a5459a77d5578206927c8062a58381af642.
  • Four real-HTTP array regressions fail on the base: Responses and Google, each in proxy and plugin-marked mode.
  • Final new, malformed-body, misrouted-endpoint, and route-passthrough suites: 22 tests passed. They cover populated and empty root arrays, with and without identity, byte-for-byte whitespace preservation, explicit passthrough, and genuine nested-array conversations that still receive the preparation metadata.
  • Full npm run typecheck, npm run build, and git diff --check: passed.
  • Codex e2e preflight finds the CLI and built artifact, but its configured upstream at 127.0.0.1:8199 is unreachable. The real-model suite was not run; the existing gate remains required.

Author history and live all-state searches found no equivalent root-array fix. #1287 guards missing messages on Anthropic/OpenAI endpoints; this closes the distinct remaining Responses/Google array path without broadening that check to valid continuation requests.

Fixes #7027

@ranxianglei ranxianglei changed the title fix: relay root JSON arrays without conversation preparation [PR] fix: relay root JSON arrays without conversation preparation Nov 17, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Review started.

Duplicate check: not a duplicate. No other open issue/PR targets the Responses/Google root-array path. It is in the same mechanism family as #1287 (non-conversation bodies relayed verbatim instead of mangled/rejected), but #1287's guard at src/server/handle.ts:829 only covers protocol === "anthropic" || "openai" — the responses/google root-array path was never reachable through it, so this PR closes a distinct remaining gap.

Initial read: the diff is one line at the conversation gate (src/server/handle.ts:1091, adding !Array.isArray(parsed)) plus a new real-HTTP regression suite. I am now verifying the claim that the array cases fail on base 301e1a5459 and pass on the head, and walking the regression surface of the gate. Full 8-question review conclusion to follow.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Review complete — verdict: mergeable once CI is green.

What I verified independently (not from the PR description):


结构化八问(中文审核结论)

  1. 是什么问题:Responses/Google 端点收到根级 JSON 数组 body 时,被当作会话对象处理——数组被展开成 {"0":...,"1":...} 数字键对象并注入会话元数据;无身份头时则被本地 400 拒绝。非会话请求不该由代理改写或代判。
  2. 什么原因导致的:会话入口闸门(src/server/handle.ts:1091)的形状判断 typeof parsed === "object" 对 JS 数组同样为真,根数组漏进会话准备管线;fix: relay non-conversation bodies verbatim instead of 400ing them (#1284) #1287 的补漏守卫只覆盖了 anthropic/openai 两类协议,responses/google 路径从未被覆盖。
  3. 影响范围与严重程度:仅影响向 responses/google 端点发送根级数组 body 的请求(无合法客户端会这么发——两类端点的合法 body 都是对象;实际触发者是误路由的非会话 API,如 [Bug] DSH native fetch 拦截误伤非 LLM 端点:任何以 /messages 结尾的 URL 都被当成模型 API #1284 的 dsh 插件写记录)。严重度:特定条件下的行为错误(p2 合理)——请求被静默改写后上游拒绝,或无身份时被本地 400 吞掉,客户端拿不到上游自己的契约错误。
  4. 怎么修复的:在闸门条件上排除根数组(!Array.isArray(parsed)),让既有 raw-forward 路径逐字节转发,由上游应用自己的契约——与 [Bug] DSH native fetch 拦截误伤非 LLM 端点:任何以 /messages 结尾的 URL 都被当成模型 API #1284/fix: relay non-conversation bodies verbatim instead of 400ing them (#1284) #1287 已确立的方向一致,修在决策点而非中途过滤字节。
  5. 是否有回归问题:无。逐项清点:① 非数组对象会话(全协议)——条件等价,不变;② anthropic/openai 根数组——在 829 行 fix: relay non-conversation bodies verbatim instead of 400ing them (#1284) #1287 守卫处已被拦截(本就排除数组),不经过本闸门,不变;③ 显式 passthrough / route-passthrough / hopMarker / chainSkip——原本就跳过闸门,不变;④ 非协议路径——闸门本就要求 protocol,不变;⑤ 嵌套数组的对象会话——负向测试钉住(断言 ACP TAGS 注入仍发生);⑥ 附带收益:数组 body 不再创建/污染会话状态(修复前带身份头的数组会造出垃圾会话)。有意行为变更(已在 issue 披露):responses/google 根数组从「本地 400 或被改写」→「原样转发由上游拒绝」。
  6. 是否破坏缓存:不涉及。数组请求不产生会话,无缓存条目、无 pf-seq 盖戳、无折叠状态;既有会话的缓存/游标/去重键均不受影响。
  7. 是否改了设计方向:否。是 [Bug] DSH native fetch 拦截误伤非 LLM 端点:任何以 /messages 结尾的 URL 都被当成模型 API #1284「非会话 body 原样转发」原则在两个漏网端点类上的补全,且把管线中最后一处缺失 !Array.isArray 的形状判断对齐到既有惯用法。
  8. 是否引入了新的配置:不涉及。

判定:可合(CI 全绿后)。diff 两文件、单 commit、无无关改动;测试为真 HTTP 字节级断言且已验证 base 红/head 绿;本地 typecheck/build 通过;base 即当前 master,无 rebase 需要。合并权在 owner。

Merge upstream master 6a641f3, including the architecture module-map and schedule-independent ranxianglei#2929 probe fixes.

Preserve the existing PR head and exact contribution patch. Validation of this refreshed head runs in upstream CI; no local test rerun is claimed.
@Afloat16

Copy link
Copy Markdown
Contributor Author

(ai: OpenAI/gpt-6-astra)

The branch is now synchronized with current master in c2084f146b9dd56c2adc419b2825c31bfee14acf. The original head and the reviewed two-file root-array fix are preserved, including identical patch contents against the new base. Current master contains the inherited CI fixes.

The refreshed head is being checked in CI run 44050377861. At 2026-11-17T09:30:54.486Z the main workflow is pending and the other eleven workflows have passed; this does not yet establish a full-suite pass.

@ranxianglei

Copy link
Copy Markdown
Owner

This fix is included verbatim (original commits and authorship preserved) in the merged batch PR #7074 — the changes are already on master. Closing to avoid a duplicate merge. 该修复已随批量 PR #7074 原样合入 master,为避免重复合并,关闭此 PR。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Root JSON arrays on Responses/Google endpoints are rewritten as conversations

2 participants