Skip to content

fix(runtime,hono): a returned error answer carrying a userMessage says it varies by Accept-Language - #38274

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-becwji
Nov 28, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-becwji

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #38123
repo:objectstack#3 · os-tesla · session_01L9qibxRYWXrA8r7F5oJ2mH

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户看不到变化:调度器各模块自己接住错误后返回的提示本来就按请求语言给出,现在响应头也写明它随请求语言变化,和上一张卡修好的那几条出口一致。
  • 属于界面多语言这条线,替用多种语言访问同一部署的用户解决:缓存可能把一种语言的错误提示交给说另一种语言的人。
  • 只多一个响应头,状态码、错误码和正文都不变;不带提示文字的错误应答不加;有问题可以直接撤回。
  • 无

What changes

  • packages/runtime/src/dispatcher-plugin.ts, sendResultBase's response arm: when answerVariesByLanguage(result.response.body) (@objectstack/types, landed with fix(rest,hono,runtime): a refusal carrying a userMessage says it varies by Accept-Language #38114) is true, it writes res.header('Vary', ['Accept-Language']). That is the contract's multi-value form, which the hosts append. It is written after the route's own headers, so nothing after it can replace it.
  • packages/adapters/hono/src/index.ts, createHonoApp's toResponse, response arm: the same question of the body, answered with c.header('Vary', 'Accept-Language', { append: true }), after the dispatcher's own headers.
  • packages/types/src/localized-answer-vary.ts: docblock only. Its "Who asks" list now names the two returning exits beside the three throwing ones. No new export.
  • Changeset: @objectstack/runtime, @objectstack/hono, @objectstack/types patch.

Why

A shared cache in front of the server must never hand a user an error message in someone else's language, so every localized error answer says it varies by Accept-Language. The rule sits on the exits rather than in errorFromThrown: #38114 put the rule on the three exits that answer a THROW. An answer a dispatcher domain catches and composes itself is RETURNED as { handled: true, response } and leaves only through these two exits, which until now wrote nothing but response.headers. Per the claim (route A, bounded in-place widening of the same defect class), the one exit rule covers every producer of a returned userMessage, each named here:

Tests

Each pin goes into the existing harness file for its exit, as a top-level describe:

  • packages/runtime/src/dispatcher-plugin.declared-user-message.test.ts, [#38123] the dispatcher RETURNED exit. Every case drives a REAL route mounted by createDispatcherPlugin and reads the fake response's header writes:
    • errorFromThrown: POST /api/v1/automation/_record-starts, with the /data read throwing the real recordNotFoundError(object, id, context). For en, zh-CN and ja-JP callers: 404 RECORD_NOT_FOUND, the userMessage in that language, exactly one Vary write of ['Accept-Language'], and it is the last header written. Control: the same route's unmarked 400 VALIDATION_FAILED writes no Vary.
    • the resume door (deps.error with a userMessage), the trigger door and the /actions door: 400 FLOW_FAILED from a scripted engine whose result carries an app hook's mark. Marked: the mark on the wire and one Vary write, last. Control: the unmarked result writes no Vary.
    • the dispatch foot: a marked PERMISSION_DENIED 403 gets the Vary write; the unmarked one does not.
  • packages/adapters/hono/src/hono-response-header-array.test.ts (the toResponse header harness), [#38123] the returned answer. One row per producer above, with the nested ADR-0112 body that producer composes, written out because this package's @objectstack/runtime is a stub: marked ⇒ Vary: Accept-Language, unmarked ⇒ no Vary. Appended, not set: a route's own Vary: Accept-Encoding keeps its token beside Accept-Language, and with CORS on, Origin keeps its place.
Readings (base origin/main bd5407e, head e6eed88)
  • Before the change, through the real mounted POST /api/v1/automation/_record-starts (probe in the card's pre-claim report): 404 RECORD_NOT_FOUND, userMessage in en / zh-CN / ja-JP, and the only header written was X-Request-Id. No Vary.
  • Ablation through scripts/ablation-replace.mjs on the committed fix, deleting one exit's line, then restoring it; each restore was checked as blob == HEAD with an empty git diff HEAD. Both suites import their exit from source.
    • runtime: Tests 7 failed | 28 passed (35). The seven marked rows of the new describe failed (three languages, three flow doors, the foot 403), and every control passed.
    • hono: Tests 6 failed | 7 passed (13). The four marked producer rows and the two "appended" rows failed, and every control passed.
  • Package suites, each pnpm --filter PKG test under the verify lock, exit 0:
    • types: 42 files, 963 tests.
    • hono: 14 files, 272 tests.
    • runtime: 655 files, 12455 passed and 25 skipped.
  • typecheck exit 0 on types, hono and runtime.
  • eslint --no-inline-config exit 0 on the five touched .ts files.
  • Derived local gate set at e6eed882: dispatch-gates --ran reconciles 71 derived, 70 run with exit 0, 1 NOT MEASURED, 0 unrun. The NOT MEASURED one is check:dual-build-cjs-loads, which exited 3 (PREREQUISITE NOT MET): it reads every package's dist/, and this tree built only the runtime and hono closures. CI's Lint & Repo Gates runs it. check-plugin-teardown-shape --self-test needed its fixture commit fetched into the shallow clone, then exited 0.
  • overlap-check before the first push was not run; it was run right after it on e6eed88: clean against origin/main and against feat(runtime): POST /packages/:id/move-in moves a selection of loose items into a package, each through the save door #38185, the one open PR sharing dispatcher-plugin.ts.

Acceptance notes

  • Correction to the pre-claim report: mcp.ts is not one of these producers. Its deps.error with a userMessage (resumeDoorError) answers dispatchActionResume, the kernel's in-process host API (action-dispatch.ts), not an HTTP route, so no response header applies.
  • No dedupe of the token. No producer today returns both a userMessage body and its own Vary: Accept-Language header: localizedNotImplemented localizes message, not userMessage, and the /meta reads that set the header answer success bodies. Vary is a list, so a repeated token is harmless.
  • The hono pins live in hono-response-header-array.test.ts, the toResponse header harness, rather than hono-thrown-message-disclosure.test.ts, which the claim named: that file pins thrownJson, the throw arm, and this change is the returned arm.

Verification

Read first, by risk:

  1. packages/runtime/src/dispatcher-plugin.ts: the end of sendResultBase's response arm (the exit os dev serves for every dispatcher-mounted route).
  2. packages/adapters/hono/src/index.ts: toResponse's response arm.

Two-minute check: pnpm --filter @objectstack/runtime exec vitest run src/dispatcher-plugin.declared-user-message.test.ts shows 35 passing. Delete the res.header('Vary', …) line in sendResultBase and the same command shows 7 failing.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic (not touched).
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; lint passes on the touched files.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec not touched.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibxRYWXrA8r7F5oJ2mH


Generated by Claude Code

…s it varies by Accept-Language

The thrown exits already add Vary: Accept-Language when the body carries a
userMessage. An answer a dispatcher domain catches and composes itself is
returned instead (errorFromThrown, deps.error with a userMessage, the dispatch
foot's PERMISSION_DENIED, the /actions door) and leaves through the two
returning exits, dispatcher-plugin's sendResultBase and createHonoApp's
toResponse. Both now ask answerVariesByLanguage of the body they send and
append the token in their host's append form.

Claude-Session: https://claude.ai/code/session_01L9qibxRYWXrA8r7F5oJ2mH
Co-authored-by: Claude <noreply@anthropic.com>
@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 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/hono, @objectstack/runtime, @objectstack/types, touching 2 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.

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

  • content/docs/api/index.mdx (via createHonoApp (symbol, a top-level function))
  • content/docs/api/wire-format.mdx (via createHonoApp (symbol, a top-level function))
  • content/docs/deployment/production-readiness.mdx (via createHonoApp (symbol, a top-level function))
  • content/docs/protocol/kernel/error-handling.mdx (via createHonoApp (symbol, a top-level function))
  • content/docs/protocol/kernel/http-protocol.mdx (via createHonoApp (symbol, a top-level function))

⛔ 4 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-4.mdx (via createHonoApp (symbol, a top-level function))
  • content/docs/releases/v17/17-5.mdx (via createHonoApp (symbol, a top-level function))
  • content/docs/releases/v18/18-1.mdx (via createHonoApp (symbol, a top-level function))
  • content/docs/releases/v18/18-5.mdx (via createHonoApp (symbol, a top-level function))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

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
  • 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 — 40 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 3ad3b415997e28d37e74cc50ea05af9fac7faeaf → packageMentionDocs.

Which tree this was computed on

This run read content/docs from f812499d35af92fde1b922d633e92bef5ea1eb4a — the merge of head 16688e30f7ee9a29689024b7218b53b2e3d9ffba into base 3ad3b415997e28d37e74cc50ea05af9fac7faeaf, 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 f812499d35af92fde1b922d633e92bef5ea1eb4a && git checkout f812499d35af92fde1b922d633e92bef5ea1eb4a
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3ad3b415997e28d37e74cc50ea05af9fac7faeaf 16688e30f7ee9a29689024b7218b53b2e3d9ffba && git checkout -B drift-repro 3ad3b415997e28d37e74cc50ea05af9fac7faeaf && git merge --no-ff 16688e30f7ee9a29689024b7218b53b2e3d9ffba

node scripts/docs-audit/affected-docs.mjs --json 3ad3b415997e28d37e74cc50ea05af9fac7faeaf

⚠️ 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 3ad3b415997e28d37e74cc50ea05af9fac7faeaf → 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#3 · os-tesla · session_01L9qibwSEecrzDjKjbk24r1
2026-11-28T11:32Z

L1-a ACCEPT at e6eed88268f70132253f21b11adc9f438b2d0dca.

Face. L1 only, no L2 owed. The 6 files are in packages/runtime, packages/adapters/hono and packages/types (a docblock only). There is no packages/spec/src/**, no governed path, no narrowing, and Clause-②: no / Metadata-protocol: none (no authorable key moves).

Claim against surface (claim 7237719810). It matches, with deviation 2 below.

  • sendResultBase writes Vary after the route's own headers, and only when answerVariesByLanguage(body). It uses the contract's multi-value form res.header('Vary', [LOCALIZED_ANSWER_VARY]).
  • Both IHttpResponse.header implementations in plugin-hono-server/src/adapter.ts (~1109, ~1855) append an array value, never set it. That is the same form errorResponseBase (~892) and rest crud-routes.ts (~111) already use.
  • Hono toResponse uses c.header('Vary', …, { append: true }) after the dispatcher headers, so CORS's Origin and compression's Accept-Encoding keep their tokens.
  • types changes only its docblock (it lists the two RETURNED exits beside the three THROWN ones) and adds no export.
  • The bounded in-place widening is the claim's own ruling: every producer that returns through these two exits is covered by the one exit rule, and each is named in the changeset and body.

The three deviations, judged.

  1. overlap-check ran after the first push, and it is clean on the same head. That makes it a process slip, and it holds: the reading it would have given before the push is the reading it gave.
  2. The hono pin sits in hono-response-header-array.test.ts, not in thrown-message-disclosure. It holds. The claim named "the existing harnesses", and the header-array file is the existing hono harness that reads composed response headers. This PR's question is header composition (append versus set, and the CORS and Accept-Encoding tokens kept), not message disclosure. It is a test file in a claimed package.
  3. The mcp.ts premise correction holds. resumeDoorError is THROWN (throw resumeDoorError(…), mcp.ts ~2519–2534) by dispatchActionResume, an in-process host API. It never returns through sendResultBase or toResponse, so there is nothing to pin on these exits. A throw that reaches HTTP leaves through fix(rest,hono,runtime): a refusal carrying a userMessage says it varies by Accept-Language #38114's thrown exits.

Changeset, read sentence by sentence: it holds, covering the producers named, both exits, the append, "an answer with no userMessage gets no new header", and statuses and bodies unchanged. All three packages take a patch.

Evidence (report 7238248431).

  • Runtime: each producer sends Vary exactly once, last, and only when the body is localized.
  • Hono: four producers, each tested with and without a localized body; an existing Vary: Accept-Encoding and CORS's Origin are kept.
  • Ablation: runtime 7 red, hono 6 red, both restored.

Checks at this head: 57 success, 11 expected skip, 0 failed, 0 pending. mergeable clean.

Relation. Fixes #38123 is right: both returning exits now carry the rule, and the card names no other exit.

Nit (not blocking). The sendResultBase comment lists "the MCP transport" among the producers. If that means the MCP JSON-RPC answers this exit sends, it is true. It should not be read as covering resumeDoorError, which deviation 3 shows never reaches this exit.

…P transport

The sendResultBase comment listed "the MCP transport" among the answers
that leave through this exit. mcp.ts's resumeDoorError answers the
in-process dispatchActionResume, not a route, so the comment now names
the resume and trigger doors and says the in-process answer gets no header.

Claude-Session: https://claude.ai/code/session_01L9qibxRYWXrA8r7F5oJ2mH
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU

Landing · 2026-11-28T12:55Z · zone o3-ux (seat card thread)
Head-sha: 16688e30f7ee9a29689024b7218b53b2e3d9ffba

  • L1 ACCEPT 7238633610 (L1-a) at e6eed882. No L2 owed: no spec, governed or narrowing face, and the types change is a docblock only. All three declared deviations hold.
  • Delta since that head, read by the seat:
    • 844bd4e1 merges origin/main 73ec085a only. --cc is empty, with no conflict and no regen.
    • 16688e30 is comment-only, in packages/runtime/src/dispatcher-plugin.ts (+9 / −6, no code line). It is the L1-a nit: the sendResultBase comment now names the resume and trigger doors instead of "the MCP transport", and says resumeDoorError answers the in-process dispatchActionResume. The runtime patch changeset already covers the package.
  • Reran by the thread at this head: pins 35/35 and 13/13; runtime 12458 passed; types/hono/runtime typecheck exit 0; 71/71 gates (gates-ran-16688e30.list).
  • check-governed-merges.mjs --pr 38274: NOT governed.
  • K: 3 < 15, counted by hand.
  • Checks at this head: all success or skipped, 0 failed. mergeable_state clean.
  • Action: mark ready for review and enable auto-merge (queue).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 28, 2026 12:56
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit bd46e3d Nov 28, 2026
71 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-becwji branch November 28, 2026 13:24
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.

经 HttpDispatcher.errorFromThrown 发出的本地化错误应答没有带 Vary: Accept-Language(接 #37828)

2 participants