Skip to content

fix(types): sendError says Vary: Accept-Language when its body carries a userMessage - #38695

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-38567-senderror-vary
Nov 30, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-38567-senderror-vary

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #38567
Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:用户无感;改记录负责人、回收站、应用包、分析批量查询这几个接口在报错带翻译提示时,响应头里多了一个“按语言区分”的声明。
  • 为什么做:本地化报错这一组修复的收尾,防止缓存把一种语言的报错提示发给另一种语言的用户。
  • 出错会怎样:最坏是某个接口多带或少带这个响应头,报错内容和状态码都不变,可以直接撤回。
  • 要你做什么:无。

What changes

  • sendError (@objectstack/types) now asks answerVariesByLanguage of the nested envelope it is about to write and, when the body carries a userMessage, appends Vary: Accept-Language (the multi-value form, as every other exit in the family does). One root fix instead of per-door patches: every door that re-sends a classified answer through sendError is covered at once.
  • EnvelopeResponse gains an optional header(name, value) member with IHttpResponse.header's shape. Optional because capturing sinks (the analytics batch's houseEnvelopeResponse, a row's classifiedAnswer) have no response to vary; every live response carries it. No caller changes.
    • This member widens @objectstack/types' published face (export * from './response-envelope.js', index.ts:36): every object that satisfied EnvelopeResponse still does. Declared Clause-②: yes (widening) after L1-a 7270364941; the level stays patch.
  • houseEnvelopeResponse (analytics-routes.ts, the batch door's wrapper) gains a header() that forwards to the wire, so a future userMessage refusal written on it keeps its Vary (L1-a non-blocking item; no gate on that wrapper sets a header today, so it has no pin).
  • The who-asks note in localized-answer-vary.ts names the new exit.
  • scripts/engine-double-contract.pinned.json records the new test's pinned engine double (check-engine-double-contract.mjs --write).

Doors this covers (read on origin/main 25ac5df), each re-sending a userMessage through sendError:

  • change-owner-routes.ts sendRefusal (single and bulk, the card's door);
  • recycle-bin-routes.ts answerThrown (sandbox-fault and classified-refusal arms, via nestedRefusalEnvelope's extra.userMessage);
  • package-routes.ts (thrown.userMessage into extra);
  • analytics-routes.ts sendWholeBatchRefusal (written on the real wire).

No door sets Vary itself and then calls sendError, so no token is doubled (checked: every LOCALIZED_ANSWER_VARY caller writes with res.json).

Tests

  • packages/rest/src/change-owner-vary-38567.test.ts: through the real POST /data/:object/:id/change-owner handler, a missing record answers 404 RECORD_NOT_FOUND with a userMessage and exactly one Vary: [Accept-Language]; CONTROL, a 403 PERMISSION_DENIED with no userMessage gets none.
  • packages/types/src/send-error-vary-38567.test.ts: the writer itself, with and without a userMessage.
  • Ablation: deleting the one res.header?.('Vary', …) line (ablation-replace.mjs), rebuilding @objectstack/types, dist preflight --absent green, turned both positive cases red (expected [] to deeply equal [ [ 'Vary', [ 'Accept-Language' ] ] ]) and left both controls green; restore leg rebuilt, preflight present in 2 built files, 2/2 and 2/2 green.

Acceptance notes

  • Other sendError doors were read for a userMessage in extra: external-datasource-routes.ts, meta-qualified-item-route.ts, meta-record-currency-backfill-route.ts, meta-unit-code-backfill-route.ts pass none today; if they ever do, the root fix covers them.
  • Per-door tests for recycle bin, packages and analytics were not added (line budget); the writer-level pin plus the change-owner route pin cover the one shared line.

Verification

Local readings at ee83cc7 (delta 51af122: `@objectstack/rest` analytics + change-owner Vary 32 files / 487 tests passed, typecheck 0, overlap-check clean)

Read first: packages/types/src/response-envelope.ts (writeErrorEnvelope, the one risk hunk), then the change-owner test.

Two-minute check: pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/change-owner-vary-38567.test.ts shows 2 passed.


Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmQu29PQequUrXXHYMn

@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 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

3 anchor(s) derived from 2 changed package(s); no hand-written page names any of them. ⚠️ 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.

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 name(s) were too generic to anchor anything (single lowercase words)
  • 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 5a77a7063e641c7380ad8ac7a9642c1cee1b065c → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 46dcff15aff15bb51435a296fe4dc522291047e1 — the merge of head 51af122ccf324fabafdf4023e08f66c28290fbf7 into base 5a77a7063e641c7380ad8ac7a9642c1cee1b065c, 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 46dcff15aff15bb51435a296fe4dc522291047e1 && git checkout 46dcff15aff15bb51435a296fe4dc522291047e1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5a77a7063e641c7380ad8ac7a9642c1cee1b065c 51af122ccf324fabafdf4023e08f66c28290fbf7 && git checkout -B drift-repro 5a77a7063e641c7380ad8ac7a9642c1cee1b065c && git merge --no-ff 51af122ccf324fabafdf4023e08f66c28290fbf7

node scripts/docs-audit/affected-docs.mjs --json 5a77a7063e641c7380ad8ac7a9642c1cee1b065c

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmQu29PQequUrXXHYMn
CI red reading · zone o3-U · 2026-11-30T05:32Z · head ee83cc7eaca23fbaf0932cbcf80c844e839f40a2

  • Test Core (9/12) (job 141648134303) failed on one case only: packages/drivers/driver-sql/src/sql-driver-38236-sqlite-bulk-insert-bound.test.ts:83 "inserts every row of a 1200-row batch …" — Error: Test timed out in 5000ms (ran 5376 ms). driver-sql: 1 failed | 4601 passed.
  • Not an assertion: a wall-clock timeout on an in-memory SQLite 1200-row insert. This PR changes writeErrorEnvelope in @objectstack/types (a header on error answers) and adds two tests; the SQLite bulk-insert path writes no error envelope. driver-sql is in the affected set only through the dependency edge.
  • Action: one re-run of the failed job (rerun-failed.mjs). A second failure with the same signature is treated as real and diagnosed; a timeout case that runs this close to its 5 s bound is a candidate finding for the test's owner either way.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmQm8PTU4AkVU5kdwEv
L1-a, the seat's L1 thread · 2026-11-30T06:09Z · first review

席位核对

REWORK @ ee83cc7 (card #38567, o3-U; 6 files, +171/−2)

Must-fix

  1. The declaration should read Clause-②: yes (widening), not Clause-②: no, in both the PR body (line 4) and .changeset/38567-send-error-vary.md.
    • EnvelopeResponse is part of the published accepted set: export * from './response-envelope.js' (packages/types/src/index.ts:36), reachable from the . entry of @objectstack/types' exports map. It gains a member, header?(name, value).
    • contract-review.md reads the published face by that exports map. A new member on an exported interface is a change to that face, and it is a widening: an object that satisfied the interface before still does.
    • The one shape it newly refuses is an object whose own header member has an incompatible signature. I found none in the repo (the only other implementer is packages/cli/src/utils/__tests__/server-body.ts, which has no header). That is the L2's to weigh.
    • The level stays patch with Metadata-protocol: none (ruling A, AGENTS.md:1035). The changeset's own last paragraph already describes the widening, so only the declaration line moves.
    • Once declared, an L2 at TIER_DEFAULT is owed. The seat routes it.

Everything else passed

  • Root fix. writeErrorEnvelope is the one write behind both sendError and sendServerFault. It now asks answerVariesByLanguage(body), the same predicate handleRouteError, crud-routes, form-routes, record-page-routes and search-routes already use. Because sendServerFault passes no extra, it never carries a userMessage, so it never varies. That is correct.
  • Append, not set. Both in-repo hosts append an array value: plugin-hono-server/src/adapter.ts:1115-1116 (c.header(name, v, { append: true })) and the middleware recorder at :1855-1857 (outHeaders.append). adapters/hono/src/index.ts:847 does the same. So "the multi-value form the hosts append, so a Vary another layer sets keeps its tokens" is true.
  • No double Vary. None of the doors that already append Vary themselves (data-action-routes:615, error-response:1199 and the others above) also route through sendError; each writes res.status().json() directly.
  • Coverage claim. change-owner (:241, :250 nested re-send), the package routes (:248) and the analytics whole-batch refusal (sendWholeBatchRefusal(wire, …), analytics-routes.ts:434-436, which writes on the real wire) all reach the new line. The recycle bin goes through the same sendError.
  • Changeset. Every sentence matches the code once the declaration is fixed.

My runs at this head (fresh worktree, rest's dependencies built)

  • packages/types/src/send-error-vary-38567.test.ts: 2/2.
  • packages/rest/src/change-owner-vary-38567.test.ts, through the real route handler: 2/2.
  • Ablation: dropping the new res.header?.('Vary', …) line and rebuilding types turns 1 red in each file. Restored.

Non-blocking

  • houseEnvelopeResponse (analytics-routes.ts:320-331), the batch door's wrapper, has no header. A house-envelope refusal written on the wrapper passes through as written (wire.status().json(body)) and gets no Vary. Today none of those carries a userMessage: enforceAuth, the two sendError 400s at :202 and :224, and the 501. A future gate that answers a userMessage there would lose it. A one-line header forward on the wrapper would close that off.

Checks at this head (read before writing): latest runs 59 success, 11 skipped, 0 failure. Counting all runs, there are 2 failures, which are the Test Core (9/12) first attempt, a driver-sql SQLite 5 s timeout. The rerun is green, and the reason is given in comment 7269782639.
Dogfood: not owed (not a narrowing). L2: owed at TIER_DEFAULT once must-fix 1 lands; the seat routes it.

…EnvelopeResponse widening (#38567)

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmQm8PTU4AkVU5kdwEv
L1-a, the seat's L1 thread · 2026-11-30T06:41Z · delta review

席位核对

ACCEPT @ 51af122 (delta from ee83cc7, REWORK 7270364941; fast-forward, one commit)

  • Must-fix 1 is resolved. Clause-②: yes (widening) now appears in the changeset and in the PR body (line 4). Metadata-protocol: none and the patch level are unchanged, as ruling A gives. check-owed-reviews already reads this PR as face declaration at TIER_DEFAULT.
  • The non-blocking item is taken. houseEnvelopeResponse (analytics-routes.ts:320-331) now forwards header(name, value) to wire. wire is the host's real response on both branches. A userMessage refusal that a shared gate writes on the wrapper in the house envelope now carries sendError's Vary through to the wire. The changeset's parenthetical, "whose house-envelope wrapper now forwards headers to the response", is true.
  • The dev's question about a duplicate Accept-Language token. I do not count it as a finding. It can happen only when a gate both appends Vary itself on the wrapper and writes a NON-house body, which sendWholeBatchRefusal then re-sends through sendError on wire. No gate on this path does that today: enforceAuth, refuseRepeatedQueryParams, the two sendError 400s and the 501 set no Vary of their own (analytics-routes.ts holds no res.header('Vary'…)). Even then, Vary is a set of field names: Accept-Language, Accept-Language varies on exactly what Accept-Language does (RFC 9110 §12.5.5), so a cache keys the same.
  • No test pins the forward. That is acceptable for a non-blocking follow-through. The change-owner pin and its ablation still cover the writeErrorEnvelope line itself.

Checks at this head (read before writing): 55 success, 13 skipped, 0 failure, 5 in progress (Test Core 1/12, 2/12, 3/12 and 5/12, and Test UI). Landing waits for them green.
L2: owed at TIER_DEFAULT (the Clause-②: yes declaration); the seat routes it. Dogfood: not owed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmQu29PQequUrXXHYMn

Contract-review-claim: session_01ADHkmQu29PQequUrXXHYMn · head 51af122 · 2026-11-30T06:43Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmQu29PQequUrXXHYMn
o3-U zone · 2026-11-30T06:43Z · contract review, face declaration

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 51af122ccf324fabafdf4023e08f66c28290fbf7
Local-runs: none
Scope: packages/types/src/response-envelope.ts + packages/rest/src/analytics-routes.ts, packages/types/src/localized-answer-vary.ts, .changeset/38567-send-error-vary.md
Security-touching: no
Rule-change-verified: none

① Derived judgments

  • The widening is one optional member, EnvelopeResponse.header?(name, value), typed exactly as IHttpResponse.header (packages/spec/src/contracts/http-server.ts:129, string | string[]). Every live response the hosts pass already carries it, so no caller changes; a capturing sink without it still satisfies the interface and gets no header (res.header?.(…)).
  • The rule for when to add Vary is not restated: writeErrorEnvelope asks answerVariesByLanguage(body) and appends LOCALIZED_ANSWER_VARY, the same predicate and token the three throw exits use. Status, code and body bytes are unchanged.
  • houseEnvelopeResponse (analytics-routes.ts:320-331) now forwards header to wire, so the analytics batch door carries the header too. This matches the changeset's parenthetical.

② Semver level

patch on @objectstack/types, Clause-②: yes (widening) on both the PR body and the changeset, Metadata-protocol: none. An optional member added to an input-side interface rejects no value it accepted before. The type-check jobs at this head are green across the workspace and consumer gates.

③ Boundary flags

  • Dev flag (a possible doubled Accept-Language token): answered by L1-a 7270921608. No gate on this path sets its own Vary, and a repeated field name in Vary keys a cache the same (RFC 9110 §12.5.5). Not a finding.
  • No new id materialisation or in-app join; SQL push-down not in play.
  • Not security-touching: the hunks add a cache-variance header and teach no permission, sharing, credential or auth behaviour.

Implemented-by: claude/issue-38567-senderror-vary
Reviewed-by: session_01ADHkmQu29PQequUrXXHYMn

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmQu29PQequUrXXHYMn
Landing · zone o3-U · 2026-11-30T06:45Z · head 51af122ccf324fabafdf4023e08f66c28290fbf7

  • L1: delta ACCEPT 7270921608 (L1-a) at this head, after REWORK 7270364941.
  • L2: face declaration, TIER_DEFAULT record PASS 7270955753 at this head (check-owed-reviews: DONE).
  • check-governed-merges --pr 38695: NOT governed, 177 changed lines ≤ 3000. landing-k: K = 0.
  • Checks at this head: 61 success, 13 expected skip, 0 failure, 0 pending.
  • Action: pr_ready + automerge_enable. The PR says Fixes #38567.

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-steve · session_01ADHkmQu29PQequUrXXHYMn
Queue kick · zone o3-U · 2026-11-30T07:06Z · head 51af122ccf324fabafdf4023e08f66c28290fbf7

Removed from the merge queue at 2026-11-30T07:04Z with CI_FAILURE, entry gh-readonly-queue/main/pr-38695-d2caaec40d… (run 46368805195).

Signature: Test Core (9/12) (job 141681622563), step Test, first error: 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, in order, as statements within both bounds — Error: Test timed out in 5000ms. at :83:3. One test of 4,870 in @objectstack/driver-sql; every other shard was cancelled after it, none failed.

Initial judgment: a timeout flake in a test this PR does not reach, not this PR's change.

  • First error is a timeout, not an assertion.
  • The queue base's own entry (PR feat(spec,ui): object pinOverview keeps the wide record page from pinning its overview #38679, run 46366968660, which landed as d2caaec40d) ran the same file green, and it ran slow there: 13 tests in 13,104 ms against a 5,000 ms per-test bound.
  • The same test timed out the same way on this PR's own run at ee83cc7e (job 141648134303, 5,376 ms), and went green on the rerun.
  • Import closure: driver-sql reaches @objectstack/types only through its barrel (isUniqueViolationError, mapDataError and the like). The barrel already loads response-envelope.ts; this diff changes only the body of writeErrorEnvelope, which bulkCreate never calls, and adds an import of localized-answer-vary.ts, which the barrel already loads. The changed code is not on the failing test's call path.

Action: re-enqueue once (automerge_enable). A second kick with this signature stops re-enqueueing and goes to diagnosis.

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: change-owner on a missing record answers a userMessage through sendError without Vary: Accept-Language

2 participants