Skip to content

chore(core): format the one file the prettier check lane still rejects - #11378

Merged
wenshao merged 1 commit into
mainfrom
fix/prettier-anthropic-sse-test
Sep 8, 2026
Merged

wenshao merged 1 commit into
mainfrom
fix/prettier-anthropic-sse-test

Conversation

@wenshao

@wenshao wenshao commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

Runs the formatter over the single file in the repository that the Prettier check still rejects. Eight lines added, ten removed, all of it one member chain reflowed — no expression changes.

Why it's needed

The Prettier lane ran --write for most of its life. As the comment above it in the lint script records, --write exits 0 whether or not anything changed and no caller inspected the tree afterwards, so the lane reported a pass on unformatted code and CI discarded the rewrites when the job ended. It now runs --check, which surfaces whatever merged under the old behaviour.

This file is the only remaining violation repo-wide. The offending construct is a fetch: vi.fn().mockResolvedValue(new Response(...)) chain in the Anthropic SSE error test, added by #11216, whose own Lint & Static job passed because the lane was still writing rather than checking at that point. Blame puts every one of those lines on that commit, and the file is byte-identical between it and current main, so this is pre-existing formatting debt rather than anything a later change introduced.

The practical effect today is that any PR running the full CI profile against a tree containing this file fails Lint & Static for a reason that has nothing to do with its own diff.

Reviewer Test Plan

How to verify

Run the same command the CI lane runs, from the repository root:

node scripts/lint.js --prettier

Before this change it exits 1 naming packages/core/src/core/anthropicContentGenerator/anthropicContentGenerator.test.ts; after, it reports All matched files use Prettier code style! and exits 0. Confirming the change is formatting-only needs no test run, but the reformatted file's own suite was run anyway and is green.

Evidence (Before & After)

N/A — no UI or TUI surface.

Before:

[warn] packages/core/src/core/anthropicContentGenerator/anthropicContentGenerator.test.ts
[warn] Code style issues found in 1 file. Run Prettier with --write to fix.
exit 1

After:

All matched files use Prettier code style!
exit 0

Tested on

OS Status
🍏 macOS ✅
🪟 Windows ⚠️
🐧 Linux ⚠️

Environment (optional)

Local, on macOS: the CI lint command repo-wide before and after, ESLint on the changed file, and that file's own vitest suite (172 tests). Prettier 3.6.1, matching the lockfile, so the local verdict and CI's agree.

Risk & Scope

  • Main risk or tradeoff: none. Prettier preserves semantics, the diff is one call chain, and the file's tests pass unchanged.
  • Not validated / out of scope: nothing. A repo-wide check confirms this was the only violation, so the lane should stay green after this lands.
  • Breaking changes / migration notes: none.

Linked Issues

None. Found while diagnosing a Lint & Static failure on #11291 that turned out to be inherited from main rather than caused by it.

中文说明

这个 PR 做了什么

对仓库里唯一一个仍被 Prettier 检查拒绝的文件跑一遍格式化。新增 8 行、删除 10 行,全部是一条成员链的重排——没有任何表达式改动。

为什么需要

Prettier 这条 lane 在其生命周期的大部分时间里跑的是 --write。正如 lint 脚本里它上方那段注释所记录的:--write 无论是否真的改动都退出 0,且没有任何调用方在事后检查工作树,于是这条 lane 会在未格式化的代码上报告通过,而 CI 在 job 结束时把重写结果丢弃。它现在跑的是 --check,这就把旧行为下混进来的东西暴露了出来。

这个文件是全仓唯一残留的违规处。出问题的构造是 Anthropic SSE 错误测试里的 fetch: vi.fn().mockResolvedValue(new Response(...)) 链,由 #11216 引入;那个 PR 自己的 Lint & Static job 是通过的,因为当时这条 lane 仍在写而不是在检查。blame 把每一行都归到该提交,且该文件在它与当前 main 之间逐字节相同,所以这是既有的格式欠账,而不是后续某次改动引入的。

它今天的实际影响是:任何针对包含此文件的代码树运行完整 CI profile 的 PR,都会因为与自身 diff 毫无关系的原因而让 Lint & Static 变红。

审阅测试计划

如何验证

在仓库根目录运行 CI lane 所用的同一条命令:

node scripts/lint.js --prettier

改动前它以 1 退出并指名 packages/core/src/core/anthropicContentGenerator/anthropicContentGenerator.test.ts;改动后报告 All matched files use Prettier code style! 并以 0 退出。确认改动纯属格式化并不需要跑测试,但仍然跑了被格式化文件自己的套件,结果全绿。

前后对比证据

N/A——不涉及 UI 或 TUI 界面。

改动前:

[warn] packages/core/src/core/anthropicContentGenerator/anthropicContentGenerator.test.ts
[warn] Code style issues found in 1 file. Run Prettier with --write to fix.
exit 1

改动后:

All matched files use Prettier code style!
exit 0

测试环境

OS Status
🍏 macOS ✅
🪟 Windows ⚠️
🐧 Linux ⚠️

环境(可选)

本地 macOS:改动前后各跑一次全仓 CI lint 命令、对改动文件跑 ESLint、并跑该文件自己的 vitest 套件(172 条)。Prettier 为 3.6.1,与 lockfile 一致,因此本地结论与 CI 一致。

风险与范围

  • 主要风险或取舍:无。Prettier 保持语义不变,diff 只有一条调用链,且该文件的测试照常通过。
  • 未验证 / 不在范围内:无。全仓检查确认这是唯一违规处,因此这条 lane 在本 PR 合入后应保持绿色。
  • 破坏性变更 / 迁移说明:无。

关联 Issue

无。是在排查 #11291 上那个 Lint & Static 失败时发现的,最终查明它是从 main 继承来的,而非该 PR 自身造成。

The Prettier lane ran `--write` for most of its life, which exits 0 whether or
not anything changed and discarded the rewrites when the job ended, so
unformatted code merged silently. It now runs `--check`, and this file is the
only remaining violation in the repository: a `vi.fn().mockResolvedValue(...)`
chain in the Anthropic SSE error test that landed before the lane changed and
passed under the old behaviour.

Formatting only — the chain is reflowed onto fewer lines, with no change to any
expression. Verified with the same command CI runs, repo-wide, and by running
the reformatted file's own tests.
@wenshao
wenshao added this pull request to the merge queue Sep 8, 2026

@qqqys qqqys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read-only review pass at head 423170ff. This is the first review on this PR, so there is no recorded blocker backlog to re-check; I scanned the complete diff instead, and it is exactly what the description says. Approving.

Critical-only scan — the whole diff is one formatter reflow, with no semantic change.

The single hunk (packages/core/src/core/anthropicContentGenerator/anthropicContentGenerator.test.ts, @@ -3394,17 +3394,15 @@) reflows one member chain, and the token sequence before and after is identical:

  • fetch: vi.fn().mockResolvedValue(new Response(...)) — same call chain, same single argument; only the line breaks and indentation that Prettier chose for it moved (vi\n.fn()\n.mockResolvedValue( collapsed to vi.fn().mockResolvedValue(, with the closing ), repositioned accordingly).
  • The template literal is byte-identical: `event: error\ndata: ${JSON.stringify({ type: 'error', error: { type, message } })}\n\n` — same SSE frame, same interpolation, same escaping.
  • The Response init object is unchanged: status: 200 and headers: { 'content-type': 'text/event-stream' }.
  • Nothing outside that chain is touched, no identifier is renamed, no argument is added, dropped or reordered, and the enclosing new ActualAnthropic({ apiKey, maxRetries: 0, fetch }) construction and the client.messages.create call that follows are untouched.

So there is no expression whose behaviour could change, and no test assertion is weakened, strengthened or removed — the 8/10 line delta is entirely the reflow. That is the whole production surface of this PR, so the scan is complete rather than partial.

The premise checks out. scripts/lint.js:309 runs prettier --experimental-cli --check ., so the lane now fails on an unformatted tree instead of silently rewriting it and exiting 0 — which is what makes a single lingering violation every other PR's Lint & Static failure rather than cosmetic debt. The file being a *.test.ts also keeps this clear of AGENTS.md's core line-counting, and the PR is maintainer-authored, so the core gate's exemption applies on both counts.

CI at this head. The head is minutes old: 8 checks pass (routing, classification and the fast legs), 76 are skipped, and 5 are still queued or in progress — including Lint & Static, the one lane this PR exists to satisfy. I did not treat pending as a gate, and nothing reported so far fails. Worth confirming that lane green before merging, since it is the only check whose verdict this change can affect; the author reports it exits 1 naming this file beforehand and 0 after, and the reformatted file's own suite is green.


中文说明:本次在 head 423170ff 上评审。这是该 PR 的第一次评审,因此没有需要复核的历史阻塞项;我改为扫描完整 diff,其内容与描述完全一致,故提交 Approve。Critical-only 扫描——整个 diff 就是一处格式化重排,无语义变更。 唯一的 hunk(packages/core/src/core/anthropicContentGenerator/anthropicContentGenerator.test.ts,@@ -3394,17 +3394,15 @@)重排了一条成员链,前后 token 序列完全相同:fetch: vi.fn().mockResolvedValue(new Response(...)) 调用链与唯一实参不变,只是 Prettier 选择的换行与缩进位置移动(vi\n.fn()\n.mockResolvedValue( 收拢为 vi.fn().mockResolvedValue(,结尾 ), 相应移位);模板字符串逐字节一致(同样的 SSE 帧、同样的插值与转义);Response 初始化对象未变(status: 200、headers: { 'content-type': 'text/event-stream' });链之外的内容一律未触及,没有标识符重命名,没有实参增删或换序,外层的 new ActualAnthropic({ apiKey, maxRetries: 0, fetch }) 构造与其后的 client.messages.create 调用均未变动。因此不存在行为可能改变的表达式,也没有任何测试断言被削弱、加强或删除——8/10 行的差量全部来自该重排。这就是本 PR 的全部生产面,所以本次扫描是完整的而非局部的。前提成立:scripts/lint.js:309 执行 prettier --experimental-cli --check .,因此该 lane 现在会在树未格式化时失败,而不是静默重写后以 0 退出——这正是"一处遗留违规会变成其他每个 PR 的 Lint & Static 失败"而非单纯格式债的原因。该文件是 *.test.ts,也不计入 AGENTS.md 的 core 行数口径,且本 PR 由维护者提交,core 门禁的豁免在两个维度上都适用。CI:head 推送仅数分钟,8 项通过(路由、分类与快速腿)、76 项跳过、5 项仍在排队或进行中——其中包括本 PR 唯一要满足的 Lint & Static。我未把 Pending 当作门禁,目前已报告的检查中没有失败。合入前值得确认该 lane 变绿,因为它是本次改动唯一可能影响结论的检查;作者报告改动前该命令以 1 退出并点名此文件、改动后以 0 退出,且重排后该文件自身的测试套件为绿。

Merged via the queue into main with commit eb891d6 Sep 8, 2026
117 of 118 checks passed
yiliang114 added a commit to yiliang114/qwen-code that referenced this pull request Sep 8, 2026
Bring the fork branch up to date with main. main's QwenLM#11378 formatted
packages/core/src/core/anthropicContentGenerator/anthropicContentGenerator.test.ts,
which the stale fork base still carried unformatted and made the Lint &
Static prettier step fail.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Patrol-Run: qwen-pr-conflict/jmtsuc0p2rq
wenshao added a commit to qqqys/qwen-code that referenced this pull request Sep 8, 2026
The lane checks out refs/pull/N/head by deliberate trade-off (the merge
ref is rebuilt asynchronously and served stale), so a green run proves
the branch passes the gate AS THE BRANCH DEFINES IT, not as the base
defines it. QwenLM#11117 flipped the Prettier lane from --write to --check on
main while QwenLM#11216's branch still ran --write; it merged green, main went
red, and every later full-profile PR failed lint for a reason outside
its own diff (QwenLM#11378 cleaned up). Nothing else catches this: the ruleset
requires reviews, not status checks, and the merge queue is off.

Add a "Check lint gate freshness" step before the expensive steps: for
each gate-defining file (lint.js, the eslint/prettier configs, ci.yml,
the check itself), compare the base's latest commit touching it against
the PR head via the swapped three-dot compare; a "diverged" or "behind"
verdict fails the lane with the offending commits and the rebase remedy.
package.json/lockfile are excluded deliberately: at 50-100 merges a day
that would re-create the update treadmill, and a prettier/eslint bump
cannot sneak semantics past a branch anyway since both run repo-wide.
API errors fail open with a warning — an advisory gate must not hold
every PR hostage during an API brownout.

The check runs its decisions through an injected fetchJson so the suites
stay network-free; the wiring test pins the step's gate, position and
env, and the gate-file list is mutation-witnessed. Verified against the
live API: a head at origin/main passes, a head at the parent of the
last ci.yml change fails naming that commit, and missing/bad tokens warn
without failing.
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.

4 participants