fix(ci): repair the lint gate and the CRLF-fragile source scan on main - #178
Merged
Merged
Conversation
Two independent defects broke the verification workflow on main:
1. `bun run lint` failed with 4x no-useless-assignment in
src/controllers/anthropic.js. In handleAnthropicStream and
handleAnthropicNonStream, `promptTokens`/`completionTokens` were
initialised to 0 and then unconditionally overwritten from the
authoritative usage object, so the initialisers were dead stores.
Remove the write-only locals and take both values as consts directly
from `usage` at the single point where they are resolved. No behavior
change: the values consumed by attributeChatUsage and the emitted
usage payload are identical.
2. tests/tool-prompt.test.js:805 failed on any CRLF checkout ("ningun
sitio de prompt/hint re-ensena la forma nativa <tool_call>"). The
per-line comment strip used a line-comment regex anchored with `$`,
and on CRLF input the dot stops before the CR so `$` matches there;
the match is not global, so the engine backtracked, matched the empty
string, and left the comment body in `code`. The rationale comments
that legitimately name `<tool_call>` then tripped the source scan.
Bound the strip by the newline instead, which is what the test
intends on both LF and CRLF checkouts.
Verified locally: lint exit 0; frontend build exit 0; test gate PASS
1146 tests / 134 suites / 0 fail (matches tests/expected-counts.json);
bun test:bun smoke PASS (8/8).
maxff77
pushed a commit
to maxff77/Qwen2API-1
that referenced
this pull request
Sep 27, 2026
… per review Review of the rebase onto Rfym21#178/Rfym21#179 found, besides the new HTML screen: - t2v asks for responseType 'json', so a non-JSON body (the captcha page, or a `data:`-wrapped challenge frame) reaches the controller as a string that parseUpstreamImageError dropped on its failed JSON.parse. The captcha page's first URL came back as the "video" with a 200, no strike, no Retry-After. On origin/main too; Rfym21#179's raw-text detection only ran on the streaming branch. String bodies now go through the same raw-text parser (parseUpstreamBody) on both the inline check and the reader. - A t2v challenge with a non-2xx status was parsed, and counted, twice (inner catch, then outer catch). The inner catch now throws it. - Image/video never reached noteChatAnswer: an answered image request could take the half-open probe and keep text blocked for another full window, and image answers did not break a run of strikes. Both answer paths now call it; a request without a prompt is rejected before it can take the probe. - A connection cut while reading a text/html body was handled as a transport failure of the POST (re-POST, account penalty, prefix invalidation) even when the captcha markers had already arrived. The bytes read are screened first. - The busy-vs-captcha wording looked only at the detector's filtered signals, so "被挤爆" without "RGV587" read as a captcha. It looks at the whole payload again, as before the rebase. - The breaker comment claimed only the probe's own answer closes a half-open breaker; any answer does. Documented, with its ceiling. Each fix has a test in chat-challenge.test.js that fails with the fix removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
maxff77
pushed a commit
to maxff77/Qwen2API-1
that referenced
this pull request
Sep 27, 2026
… per review Review of the rebase onto Rfym21#178/Rfym21#179 found, besides the new HTML screen: - t2v asks for responseType 'json', so a non-JSON body (the captcha page, or a `data:`-wrapped challenge frame) reaches the controller as a string that parseUpstreamImageError dropped on its failed JSON.parse. The captcha page's first URL came back as the "video" with a 200, no strike, no Retry-After. On origin/main too; Rfym21#179's raw-text detection only ran on the streaming branch. String bodies now go through the same raw-text parser (parseUpstreamBody) on both the inline check and the reader. - A t2v challenge with a non-2xx status was parsed, and counted, twice (inner catch, then outer catch). The inner catch now throws it. - Image/video never reached noteChatAnswer: an answered image request could take the half-open probe and keep text blocked for another full window, and image answers did not break a run of strikes. Both answer paths now call it; a request without a prompt is rejected before it can take the probe. - A connection cut while reading a text/html body was handled as a transport failure of the POST (re-POST, account penalty, prefix invalidation) even when the captcha markers had already arrived. The bytes read are screened first. - The busy-vs-captcha wording looked only at the detector's filtered signals, so "被挤爆" without "RGV587" read as a captcha. It looks at the whole payload again, as before the rebase. - The breaker comment claimed only the probe's own answer closes a half-open breaker; any answer does. Documented, with its ceiling. Each fix has a test in chat-challenge.test.js that fails with the fix removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Why
mainat 928f816 has a redverify / regressionjob. The failing step is 7.Run bun run lint, which means step 8 (bun run test) is skipped — so the regression suite has not actually run on this commit. Fixing only the lint error would turn CI green while the second defect below stays hidden; both are included here.Reproduced locally on a clean checkout of 928f816.
1.
bun run lintfails with 4xno-useless-assignmentIn both
handleAnthropicStreamandhandleAnthropicNonStream, the two counters were initialised to0and then unconditionally overwritten from the authoritative usage object:The initialisers are dead stores: nothing reads the variables before the assignment. The locals are write-only intermediates, so they are removed and both values are taken as
constdirectly fromusageat the single point where they are resolved.No behaviour change — the values passed to
attributeChatUsageand written into the emittedusagepayload are byte-for-byte the same. This is a pure dead-store removal, not a change to how usage is resolved or estimated.2.
tests/tool-prompt.test.js:805fails on any CRLF checkoutThat test scans
chat.js/anthropic.js/request.jsto pin at source level that no model-readable string re-teaches the native<tool_call>form. It deliberately strips comments first, because the rationale comments in the tree legitimately name<tool_call>:The per-line strip is anchored with
$. On CRLF input.does not match\r, so$matches before the CR, and because that regex has nogflag the engine backtracks to the empty match at position 0 — leaving the entire comment body incode, including the<tool_call>the test means to exclude. It then trips on its own rationale comments:// 错误列表(hasParseError 永远为真,即使重试本身成功),而一个被截断的 <tool_call>Bounding the strip by the newline instead is what the test intends, and behaves identically on LF:
Also worth noting for triage: this is a git checkout dependency, not a platform one —
core.autocrlf=true(default on Windows) is enough to trigger it, and the repo has no.gitattributespinning* text=auto eol=lf. Adding one would be a more structural follow-up, but I kept this PR to the two defects so it stays reviewable.Verification
Run on Windows, Bun 1.4.2 (from
package.json), Node v24.21.0, matching the workflow's environment:bun run lintbun run testbun run build:frontendbun run test:bun1146 / 134 / 0 failmatchestests/expected-counts.jsonexactly, so the count gate is satisfied rather than merely non-failing. The smoke run covers real Bun startup, login, frontend, WASM, HTTP/SSE (including a 16 s upstream delay), and agent mid-stream quota failover.Verified the patch applies cleanly onto a fresh clone of
mainat 928f816 before opening this PR.