Skip to content

[PR] fix(relay): skip the #821 null-body warn for HEAD responses - #7420

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-21_issue7072-head-null-body-warn
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-21_issue7072-head-null-body-warn

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

A 2xx response with a null body logs the #821 warn ([unknown] ← upstream 200 returned a null body; responding empty to client). For HEAD requests that warn is pure noise: a HEAD response has no body by definition (RFC 9110 §9.3.2), so a 200 HEAD with a null body is normal, not the #821 anomaly.

Health probes (e.g. HEAD /api/hello) hit the relay's 2xx null-body branch on every request and flood bili.log with that warn line — the exact [unknown] lines in the #7072 report.

Fix

The relay's 2xx null-body branch now skips the warn for HEAD while still warning for a genuine 2xx null body (204/304 on a body-bearing method).

src/server/relay.ts — the #821 branch: else → else if (req.method !== "HEAD").

No behavior change

The response is still relayed empty for HEAD (the client gets the 200 with no body, exactly as before). Only the spurious warn is suppressed. The #821 warn for a real 2xx null body (204/304) is unchanged.

Test

tests/issue7072-head-null-body.test.ts — both directions:

Verified the HEAD test fails on the unpatched code with the exact noise line from the report.

Scope note

This addresses the HEAD-probe noise identified in the #7072 comment. The original question — whether a POST /v1/messages that returns 200 with a null body should be surfaced as a retryable upstream error instead of an empty 200 — is a separate behavior decision and remains open (it needs the reporter's log to confirm whether the 10:14/10:15 warn lines were HEAD probes or real empty Messages, plus a call on the error shape).

Related to #7072

A HEAD response has no body by definition (RFC 9110 §9.3.2), so a 200
HEAD with a null body is normal, not the #821 anomaly. Health probes
(e.g. HEAD /api/hello) hit the relay's 2xx null-body branch on every
request and flooded bili.log with `[unknown] ← upstream 200 returned a
null body` lines — the exact noise in the #7072 report. The relay now
skips the warn for HEAD while still warning for a genuine 2xx null body
(204/304 on a body-bearing method).

No behavior change: the response is still relayed empty for HEAD (the
client gets the 200 with no body, as before); only the spurious warn is
suppressed.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-21_issue7072-head-null-body-warn (83c0e04)

Latest build — install this exact version

npm install -g billion-context@0.0.11121-pr.7420.edb36ef

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
83c0e04 billion-context@0.0.11121-pr.7420.edb36ef build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr7420.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(relay): skip the #821 null-body warn for HEAD responses [PR] fix(relay): skip the #821 null-body warn for HEAD responses Nov 20, 2026
@ranxianglei ranxianglei added bug Something isn't working p3 scope/wiring labels Nov 20, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 — searched open+closed issues and PRs for the null-body / HEAD / #821 fix family: no other PR or issue targets this fix; the only related thread is #7072 (which this PR partially addresses), and no parallel [PR] row in the mirror targets #7072.

标签: bug + p3 + scope/wiring(mirror issue 与 PR #7420 均已打) — 纯日志噪音修复,无功能变更;relay = 协议边界,故 scope/wiring;仅日志刷屏,故 p3。

Verification (branch 2026-11-21_issue7072-head-null-body-warn, head 83c0e04)

  • Diff: 2 files, +120/−1. src/server/relay.ts — the 2xx null-body branch: else → else if (req.method !== "HEAD") with an explanatory comment; tests/issue7072-head-null-body.test.ts (new, both directions).
  • Local targeted run (PR branch): 2/2 pass.
  • Negative control: reverted the one line locally and re-ran — the HEAD test fails with the exact noise line from the Upstream 200 with null body is relayed as empty response; Claude Code fails turn with 'empty or malformed response' #7072 report ([unknown] ← upstream 200 returned a null body; responding empty to client) while the GET 204 test still passes; file restored afterwards. The PR's claim is verified.
  • Code review: the branch sits on the 2xx path (after the error path); req.method is already in scope (used lines above for throttle resolution); the resetAfterSuccess (native compact) branch is untouched and is an earlier branch anyway; HEAD responses are still relayed empty — only the log line is suppressed. No wire, format, config, or kernel changes.
  • Test quality: real proxy + fake upstream, listen(0) ports, log-capture assertions in both directions (gate discipline: positive + negative).

CI status (verified live)

八问

  1. 是什么问题: relay 的 workbuddy报错Empty stream: upstream gateway sent only placeholder chunks without any model output (chunks=0, bytes=0) #821 null-body 警告对任何 2xx 空体响应都会打;但 HEAD 响应按定义就没有 body(RFC 9110 §9.3.2),所以健康探测(如 HEAD /api/hello)每次请求都刷一条 [unknown] ← upstream 200 returned a null body —— 正是 Upstream 200 with null body is relayed as empty response; Claude Code fails turn with 'empty or malformed response' #7072 报告里那批 [unknown] 噪音行(报告日志显示 66 条警告 ↔ 67 次 HEAD 探测,间隔 5–70 ms)。
  2. 什么原因导致的: relay 的 2xx 空体分支是为 workbuddy报错Empty stream: upstream gateway sent only placeholder chunks without any model output (chunks=0, bytes=0) #821 异常(带 body 的方法收到 204/304)写的,没有排除 HEAD;HEAD 合法地没有 body,于是每次探测都命中该警告。
  3. 影响范围与严重程度: 仅日志噪音 —— 每次 HEAD 探测刷一条 warn,bili.log 被淹没;无功能影响(客户端本就收到正确的空 200)。p3:日志噪音/外观级。
  4. 怎么修复的: 请求方法为 HEAD 时跳过该 warn(else → else if (req.method !== "HEAD"));带 body 方法的 2xx 空体警告保留。响应路径不变。
  5. 是否有回归问题: 触碰路径的既有行为逐项审过 —— GET/POST 的 2xx 空体仍打 warn(GET 204 测试钉住);HEAD 2xx 响应仍按原样空转发(只抑制日志行);resetAfterSuccess 分支未动;无 wire/格式/阈值/时序变化。负向对照已验证(未打补丁的代码 HEAD 测试必挂,且报错行与报告逐字一致)。
  6. 是否破坏缓存: 不涉及 —— 未触碰任何缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向: 没有。
  8. 是否引入了新的配置: 没有。

Scope note(PR 原文): #7072 的原始问题 —— POST /v1/messages 返回 200 空体是否应作为可重试的 upstream 错误暴露(而不是空 200)—— 是独立的行为决策,仍在 #7072 上开放(需要报告者的日志确认 10:14/10:15 的警告行是 HEAD 探测还是真实空 Messages,外加错误形态的拍板)。本 PR 刻意不碰它。

判定: 代码已验证(本地定向 2/2 + 负向对照),标签已打,CI attempt 2 进行中(卡死的 attempt 1 已 cancel 重跑)—— test 分片转绿后即可合并;合并权在人类。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI update: attempt 2 is fully green. All 11 CORE test shards success + all static gates + all e2e lanes — 0 failed, 1 skipped, on head 83c0e04.

The PR's mergeable_state: blocked is now solely the three test (windows-latest, 24, N) required checks — those are FULL-scope-only legs that never run on PR heads in this repo (verified: merged PR #7173 has zero windows-24 runs on its head, and no open PR carries ci:full), so blocked is the standing state for every PR here; the FULL legs run on master via the 30-min cron and the merge is a human action as usual.

Nothing further needed from the agent side — ready for human merge.

This branch has not been deployed

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

Labels

bug Something isn't working p3 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant