Skip to content

fix(rest): handleRouteError says Vary: Accept-Language on a refusal carrying a userMessage - #38585

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/project-thread-0l6mxt
Nov 29, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/project-thread-0l6mxt

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Jianguo · project thread

Fixes #38542
Supersedes #38565 (closed, 7256275666)

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:元数据、批量写入、审批、记录操作等接口出错时,如果错误里带有给最终用户看的那句话,响应会声明“内容随请求语言不同”;其余情况用户无感。
  • 为什么做:属于多语言错误提示这一组修复,补上 rest 包里那个公共出错出口,让共享缓存不会把一种语言的出错句子给另一种语言的请求;这一版只改了发布说明的文字。
  • 出错会怎样:最坏是批量换负责人或转交工作时某一行被拒,整个请求变成服务器错误;已用测试锁住这种情况,改动可直接撤回。
  • 要你做的:无。

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 current main. 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, adds Vary: Accept-Language when answerVariesByLanguage(resolved.body) holds, in the multi-value form the hosts append (res.header('Vary', [LOCALIZED_ANSWER_VARY])), the same call crud-routes.ts's sendRefusal and 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.
  • Measured first (card Ask 0): every arm of resolveErrorResponse ends in mapDataError or withDeclaredUserMessage, and both ride a producer-declared userMessage onto 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 a userMessage is unaffected.
  • Two callers use the exit as a classifier through a fake response: change-owner-routes.ts (classifiedAnswer) and user-work-routes.ts (rowFailureAnswer). Each sink now answers a no-op header(). Without that, a row refusal carrying a userMessage made the whole hand-over answer 500 INTERNAL_ERROR (TypeError: res.header is not a function). handleRouteError stays strict to the IHttpResponse contract, with no guard. batch-routes.ts's namingFailedOperation builds its wrapper with Object.create(res), so it inherits the real header.
  • The who-asks note in packages/types/src/localized-answer-vary.ts names this exit (comment only, card Ask 2).
  • Changeset .changeset/38542-handle-route-error-vary.md, review round 1 (L1 7255857505 items 1 and 2):

The three commits after 78a2fb1669 and their four files

These 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.

  • 106f5fbf08 touched scripts/engine-double-contract.pinned.json: the new suite's two engine doubles check each update call with assertEngineUpdateDispatch, and the ledger pins that suite's update verb (pinned 2), as check:engine-double-contract asks of a new double. The same commit reshaped those doubles in the new test file.
  • 196639a153 touched packages/rest/src/analytics-fault-user-message.test.ts, packages/rest/src/error-response-structured-arm-door-parity.test.ts and packages/rest/src/rest-user-facing-refusal-marking.test.ts: each suite hands the shared exit a response fake, which must now answer header() because the exit calls it on a body carrying a userMessage. One added line per fake; no assertion changed.
  • 5dba7a1f74 touched packages/rest/src/analytics-fault-user-message.test.ts and packages/rest/src/rest-user-facing-refusal-marking.test.ts again: each adds import '@objectstack/objectql' so the engine's first load is paid at collection, as the first-load rule of check:test-source-alias asks 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:
    • data action POST /data/:object/:id/clone: the localized 404 RECORD_NOT_FOUND;
    • metadata read GET /meta/:type/:name/references: a refusal with its own userMessage;
    • batch write POST /data/:object/batch: a hook refusal with its own userMessage;
    • each with a CONTROL (the same refusal with no userMessage gets no Vary);
    • the two sinks: a row refusal with a userMessage is listed as a failed row (200), not a 500.
Readings at 9f9de2b
  • Head 9f9de2be4b is bea8167c (the changeset edit on top of 5dba7a1f74) merged with origin/main 696d02f5.
  • Under the verify lock, pnpm --filter '@objectstack/rest^...' build --concurrency=2, then vitest run --maxWorkers=2 on route-error-vary-38542, change-owner-routes, user-work-routes, rest-refusal-vary-38507, analytics-fault-user-message, error-response-structured-arm-door-parity and rest-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), then pnpm --filter @objectstack/rest --filter @objectstack/types typecheck: VERDICT command-exit 0, Test Files 7 passed (7), Tests 151 passed (151).
  • Local gates, each exit captured before any pipe, all exit 0: check:nul-bytes, check:engine-double-contract, check-empty-changeset --base origin/main, check-changeset-no-major --base origin/main, check-closing-keyword-parity, check-adr-0087-registration --base origin/main, check:issue-citations, check:doc-authoring, check:cross-package-test-inputs, check:changeset-gate-self-tests. The other derived families are left to CI and its check-runs on this head.

Acceptance notes

  • Double token, read only and not run: some metadata read success paths (meta-item-read-routes.ts, meta-collection-routes.ts, meta-app-bundle-routes.ts) set Vary: Accept-Language in the single-value form before calls that can still throw into this exit. A refusal with a userMessage thrown there would carry the token twice. A repeated Vary token means the same thing (RFC 9110 12.5.5).
  • Same family, measured and left out of this PR: the single Change Owner door (POST /data/:object/:id/change-owner) re-sends the classified answer in the nested envelope through sendError and does not go through this exit. For a missing row it answers 404 RECORD_NOT_FOUND with a userMessage and no Vary. Carrier: rest: change-owner on a missing record answers a userMessage through sendError without Vary: Accept-Language #38567.
  • The ablations below were run on the fix(rest): handleRouteError says Vary: Accept-Language on a refusal carrying a userMessage #38565 branch (heads 7d622fe7 and 78a2fb16) and are not re-run here: this round changes no code or test line.
    • Ablation 1, error-response.ts restored to the base on disk: the three cases that assert Vary went red and the three CONTROLs stayed green.
    • Ablation 2, both sinks' header() removed: the two sink cases went red with the 500 described above.
  • The leftover probe branch claude/issue-38542-handle-route-error-vary-wip is for the seat to delete after this lands.

Verification

Read first: .changeset/38542-handle-route-error-vary.md (this round's only edit), then packages/rest/src/error-response.ts (handleRouteError, the one added line), then the two sinks in change-owner-routes.ts and user-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

…ge body (WIP)

Co-Authored-By: Claude <noreply@anthropic.com>
…family

Co-Authored-By: Claude <noreply@anthropic.com>
…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>
…e routes from the route-error Vary note

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jS3g8S6XJojU8e3EAp
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/rest, @objectstack/types, touching 11 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/types/src/localized-answer-vary.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/data-api.mdx (via /:object/:id/change-owner (route, bridged from symbol rowFailureAnswer — its route source's handler names it), /:object/change-owner (route, bridged from symbol rowFailureAnswer — its route source's handler names it))
  • content/docs/permissions/administrator-guide.mdx (via /security/users/:id/assigned-work/transfer (route, bridged from symbol rowFailureAnswer — its route source's handler names it))
  • content/docs/protocol/kernel/error-handling.mdx (via handleRouteError (symbol, a top-level function))
What this run could not see
  • 1 changed file(s) yielded no anchor (packages/types/src/localized-answer-vary.ts) — pages documenting those are invisible to this run
  • 1 cross-cutting symbol(s) contributed no route anchor: handleRouteError (21 routes)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 27 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 696d02f587184095c7b36600c4395cac42dbdd08 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 29e692fb33f7cf8a73cc8217cf6b4ee4560b3c05 — the merge of head 9f9de2be4b340a484f7d4e9f78c1d78fc7ec438f into base 696d02f587184095c7b36600c4395cac42dbdd08, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 696d02f587184095c7b36600c4395cac42dbdd08 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · zhuangjianguo · session_01QsR2jSyQBDMyRnrrWKy7WS

席位核对 — ACCEPT · delta L1 by seat repo:objectstack#1, review thread R1 · Head-sha 9f9de2be4b340a484f7d4e9f78c1d78fc7ec438f · 2026-11-29T13:31Z

Delta against L1 REWORK 7255857505 (on #38565 at 5dba7a1f74). Card #38542 under claim 7255570571 as amended by 7256078743; os-dev report 7256213950. This pull carries #38565's commits unchanged, one commit bea8167c61 for the REWORK, and main merged in.

  • What changed since the reviewed head. The two net diffs differ in .changeset/38542-handle-route-error-vary.md and nowhere else. The code, the tests and the ledger line are byte-identical to what 7255857505 read and accepted, so that reading stands.
  • Item 1, closed. The changeset now carries '@objectstack/types': patch and a second paragraph a consumer can read: the who-asks note beside LOCALIZED_ANSWER_VARY names the shared REST route error exit, documentation only. l1-face --pr 38585 reads the changeset item ok for both published packages.
  • Item 2, closed. The route list reads "the approval and UI routes"; "ownership-change" is struck, and that door stays with card rest: change-owner on a missing record answers a userMessage through sendError without Vary: Accept-Language #38567.
  • Item 3, closed. The body has a section on the three commits after 78a2fb1669 (106f5fbf08, 196639a153, 5dba7a1f74) and their four files with a reason each, and its readings are pinned to this head. The claim amendment 7256078743 admits the four files to the surface.
  • Checks at this head. 60 success, 13 expected skips, 0 pending, and one failed run that is stale (the single flag l1-face --pr 38585 raises). The one red in the list is the first run of the PR-body guards at 2026-11-29T12:59Z, when fix(rest): handleRouteError says Vary: Accept-Language on a refusal carrying a userMessage #38565 was still open with the same Fixes #38542. fix(rest): handleRouteError says Vary: Accept-Language on a refusal carrying a userMessage #38565 is closed (7256275666) and the guard's run of 2026-11-29T13:06Z on this head is green. check-expected-skips --pr 38585: all 13 skipped runs are in main's roster. Not governed (check-governed-merges --pr 38585: 0 of 10 paths, 307 changed lines). No contract review is owed: Clause-②: no, no schema, no rule.
  • Landing. Not governed, so it goes to the merge queue in this stroke. On merge the card closes by Fixes, pm:dispatched comes off rest: handleRouteError, the shared exit of 43 catches, answers a userMessage body without Vary: Accept-Language #38542, and the leftover branches claude/issue-38542-handle-route-error-vary and claude/issue-38542-handle-route-error-vary-wip are deleted.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 29, 2026 13:31
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 46268026930 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (9/12) — 失败步骤: Run this shard's tests

    @objectstack/driver-sql:test:  FAIL  src/sql-driver-38236-sqlite-bulk-insert-bound.test.ts > [#38236] bulkCreate on SQLite past one INSERT statement's bounds > inserts every row of a 1200-row batch, i
      ↳ 失败原因: @objectstack/driver-sql:test: Error: Test timed out in 5000ms.
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • src/sql-driver-38236-sqlite-bulk-insert-bound.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 6 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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 9f9de2be4b340a484f7d4e9f78c1d78fc7ec438f. ACCEPT 7256607793 stands. Triage comment 7256919698; the timeline shows removed_from_merge_queue at 2026-11-29T13:50Z.

Signature. Queue build 46268026930, job Test Core (9/12) (141363140709): @objectstack/driver-sql, src/sql-driver-38236-sqlite-bulk-insert-bound.test.ts, case "inserts every row of a 1200-row batch, in order, as statements within both bounds", Error: Test timed out in 5000ms. 1 failed of 4870 tests in that package; the other shards were cancelled after it. The triage comment finds no other pull with this signature in 24 hours (a lower bound), so I treat it as a new signature and re-queue once on the three facts.

  1. The diff cannot reach the failing test. This pull changes packages/rest/src/**, one ledger line in scripts/, the changeset, and packages/types/src/localized-answer-vary.ts. The test loads driver-sql, which imports @objectstack/types, so by file path the closure does meet the diff at that one file. The hunk there is three lines inside a docblock (the who-asks note); no statement, export or type changes, and the built module is the same. I count the fact as holding on that ground and say so plainly, so that a reader who holds the fact to file paths can overrule it.
  2. The same shard is green on the queue's base. The build was on main at 75108ea6df (the merge of fix(create-objectstack): name the help articles in the scaffold summary and descriptions #38584). That tree's own queue build, 46266429902, ran Test Core (9/12) green.
  3. The first error is a timeout, not an assertion. No value, shape or refusal is asserted wrong; the case ran out of its 5000 ms default under the full-suite load.

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.

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

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rest: handleRouteError, the shared exit of 43 catches, answers a userMessage body without Vary: Accept-Language

2 participants