Repository navigation
fix(rest): handleRouteError says Vary: Accept-Language on a refusal carrying a userMessage - #38585
Conversation
…ge body (WIP) Co-Authored-By: Claude <noreply@anthropic.com>
…family Co-Authored-By: Claude <noreply@anthropic.com>
…ndle-route-error-vary
…s; name the exit in the who-asks note Co-Authored-By: Claude <noreply@anthropic.com>
…n them in the ledger Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…e routes from the route-error Vary note Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jS3g8S6XJojU8e3EAp
📓 Docs Drift CheckThis PR changes 2 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 27 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 29e692fb33f7cf8a73cc8217cf6b4ee4560b3c05 && git checkout 29e692fb33f7cf8a73cc8217cf6b4ee4560b3c05
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 696d02f587184095c7b36600c4395cac42dbdd08 9f9de2be4b340a484f7d4e9f78c1d78fc7ec438f && git checkout -B drift-repro 696d02f587184095c7b36600c4395cac42dbdd08 && git merge --no-ff 9f9de2be4b340a484f7d4e9f78c1d78fc7ec438f
node scripts/docs-audit/affected-docs.mjs --json 696d02f587184095c7b36600c4395cac42dbdd08
|
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS 席位核对 — ACCEPT · delta L1 by seat repo:objectstack#1, review thread R1 · Head-sha
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46268026930 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS 2026-11-29T14:07Z · Queue eviction read and one re-queue, seat repo:objectstack#1, review thread R1, at the unchanged head Signature. Queue build 46268026930, job
Re-queued in this stroke. If the same signature returns, I stop and hand the diagnosis to the seat; I do not re-queue a second time. Suspected new flake, for the ledger's owner to judge: a 1200-row SQLite bulk insert on the default 5 s test timeout. |
Requested by Jianguo · project thread
Fixes #38542
Supersedes #38565 (closed, 7256275666)
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
This PR carries the branch of #38565 forward from its head
5dba7a1f74, adds one text commit for the review round, and merges the currentmain. The code is the code #38565 was reviewed at; only the changeset text and this body changed.handleRouteError(packages/rest/src/error-response.ts), the shared error exit of 43 catches in 14 files, addsVary: Accept-LanguagewhenanswerVariesByLanguage(resolved.body)holds, in the multi-value form the hosts append (res.header('Vary', [LOCALIZED_ANSWER_VARY])), the same callcrud-routes.ts'ssendRefusaland the four catches fixed for rest: five /data-adjacent catches outside crud-routes.ts answer mapDataError without Vary: Accept-Language #38507 make. Status, code and body are unchanged. One change at the shared exit, none per caller.resolveErrorResponseends inmapDataErrororwithDeclaredUserMessage, and both ride a producer-declareduserMessageonto the body whatever the status. So any caller can answer one when its throw declares one. The rule keys on the body, so a caller whose throws never declare auserMessageis unaffected.change-owner-routes.ts(classifiedAnswer) anduser-work-routes.ts(rowFailureAnswer). Each sink now answers a no-opheader(). Without that, a row refusal carrying auserMessagemade the whole hand-over answer500 INTERNAL_ERROR(TypeError: res.header is not a function).handleRouteErrorstays strict to theIHttpResponsecontract, with no guard.batch-routes.ts'snamingFailedOperationbuilds its wrapper withObject.create(res), so it inherits the realheader.packages/types/src/localized-answer-vary.tsnames this exit (comment only, card Ask 2)..changeset/38542-handle-route-error-vary.md, review round 1 (L1 7255857505 items 1 and 2):'@objectstack/types': patchwith one sentence: the who-asks note besideLOCALIZED_ANSWER_VARYnames the shared REST route error exit (handleRouteError). The note ships in that package's publisheddist/index.d.ts;sendError, not this exit, and gets noVaryhere; that door is rest: change-owner on a missing record answers a userMessage through sendError without Vary: Accept-Language #38567.The three commits after
78a2fb1669and their four filesThese landed on the #38565 branch after its body was written. Each is a consequence of the fix, read and accepted in L1 7255857505, and admitted to the claim surface by amendment 7256078743.
106f5fbf08touchedscripts/engine-double-contract.pinned.json: the new suite's two engine doubles check eachupdatecall withassertEngineUpdateDispatch, and the ledger pins that suite'supdateverb (pinned 2), ascheck:engine-double-contractasks of a new double. The same commit reshaped those doubles in the new test file.196639a153touchedpackages/rest/src/analytics-fault-user-message.test.ts,packages/rest/src/error-response-structured-arm-door-parity.test.tsandpackages/rest/src/rest-user-facing-refusal-marking.test.ts: each suite hands the shared exit a response fake, which must now answerheader()because the exit calls it on a body carrying auserMessage. One added line per fake; no assertion changed.5dba7a1f74touchedpackages/rest/src/analytics-fault-user-message.test.tsandpackages/rest/src/rest-user-facing-refusal-marking.test.tsagain: each addsimport '@objectstack/objectql'so the engine's first load is paid at collection, as the first-load rule ofcheck:test-source-aliasasks of a suite that reaches the engine.Tests
packages/rest/src/route-error-vary-38542.test.ts, 8 cases, one route per caller family, each through the real route and the real exit:POST /data/:object/:id/clone: the localized404 RECORD_NOT_FOUND;GET /meta/:type/:name/references: a refusal with its ownuserMessage;POST /data/:object/batch: a hook refusal with its ownuserMessage;userMessagegets noVary);userMessageis listed as a failed row (200), not a 500.Readings at 9f9de2b
9f9de2be4bisbea8167c(the changeset edit on top of5dba7a1f74) merged withorigin/main696d02f5.pnpm --filter '@objectstack/rest^...' build --concurrency=2, thenvitest run --maxWorkers=2onroute-error-vary-38542,change-owner-routes,user-work-routes,rest-refusal-vary-38507,analytics-fault-user-message,error-response-structured-arm-door-parityandrest-user-facing-refusal-marking(every suite the branch touches, plus the rest: five /data-adjacent catches outside crud-routes.ts answer mapDataError without Vary: Accept-Language #38507 sibling), thenpnpm --filter @objectstack/rest --filter @objectstack/types typecheck: VERDICT command-exit 0, Test Files 7 passed (7), Tests 151 passed (151).Acceptance notes
meta-item-read-routes.ts,meta-collection-routes.ts,meta-app-bundle-routes.ts) setVary: Accept-Languagein the single-value form before calls that can still throw into this exit. A refusal with auserMessagethrown there would carry the token twice. A repeatedVarytoken means the same thing (RFC 9110 12.5.5).POST /data/:object/:id/change-owner) re-sends the classified answer in the nested envelope throughsendErrorand does not go through this exit. For a missing row it answers404 RECORD_NOT_FOUNDwith auserMessageand noVary. Carrier: rest: change-owner on a missing record answers a userMessage through sendError without Vary: Accept-Language #38567.7d622fe7and78a2fb16) and are not re-run here: this round changes no code or test line.error-response.tsrestored to the base on disk: the three cases that assertVarywent red and the three CONTROLs stayed green.header()removed: the two sink cases went red with the 500 described above.claude/issue-38542-handle-route-error-vary-wipis for the seat to delete after this lands.Verification
Read first:
.changeset/38542-handle-route-error-vary.md(this round's only edit), thenpackages/rest/src/error-response.ts(handleRouteError, the one added line), then the two sinks inchange-owner-routes.tsanduser-work-routes.ts.Two-minute check:
pnpm --filter @objectstack/rest exec vitest run src/route-error-vary-38542.test.ts. Expected: 8 passed.Account: zhuangjianguo
🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jS3g8S6XJojU8e3EAp