Repository navigation
fix(service-print, spec): the print door's 5xx sentences follow the request's language - #37272
objectstack-fleet[bot] wants to merge 1 commit into
Conversation
…equest's language serverAnswerFor answered fixed English for 503, 504 and the 500 fallback, and the caller-resolution 500 did the same, whatever the request's Accept-Language. The four sentences are now print_* keys of the platform's operation-message catalog (BUILTIN_OPERATION_MESSAGES) in en, zh-CN, ja-JP and es-ES, written through operationUserMessage in the request's top Accept-Language tag. English is byte-identical to the old text. Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 177 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 97c160b65ebc105e8f484700fe6c88081e107428 && git checkout 97c160b65ebc105e8f484700fe6c88081e107428
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 057cedfa9b6f990a7cf322118ae33bc4460ddc65 3dfbfdb5a135338fd76d80ceab81442c2315d4df && git checkout -B drift-repro 057cedfa9b6f990a7cf322118ae33bc4460ddc65 && git merge --no-ff 3dfbfdb5a135338fd76d80ceab81442c2315d4df
node scripts/docs-audit/affected-docs.mjs --json 057cedfa9b6f990a7cf322118ae33bc4460ddc65
|
Fixes #37260
repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
packages/spec/src/system/operation-message.ts: four keys in the platform's operation-message catalog (BUILTIN_OPERATION_MESSAGES), in all four locales it carries (en,zh-CN,ja-JP,es-ES):print_engine_unavailable(503),print_timed_out(504),print_failed(the 5xx fallback) andprint_caller_unresolved(the door's caller-resolution 500). English is byte-identical to the fixed text the door answered before. No placeholder; the header documents them beside the other keys.packages/services/service-print/src/print-routes.ts:serverAnswerFor(status, locale)maps the status to its catalog key and renders it throughoperationUserMessage(@objectstack/core), the shared helper the platform's other localized refusals use;relayPrintFailureand the caller-resolution fault pass the request's topAccept-Languagetag (preferredLocaleFromHeader). The door reads no query parameter, so?localeis not a source. Code, status, the fault log and the 4xx relay are unchanged.packages/services/service-print/vitest.config.ts: aliases@objectstack/spec/systemto source like the other spec subpaths, so the new import is judged against this checkout, never a staledist/.The mechanism reused, not a new one: the operation-message catalog plus
operationUserMessageis the platform's one seat for localized user-facing server sentences (its header: "a second mechanism for the second producer is exactly what this module exists to prevent"). The door'smessageitself is localized, becausesendServerFault'smessageis already the route's generic user-facing text (the thrown detail goes only to the fault log) andsendServerFaultdeclares nouserMessagechannel; widening it would change an@objectstack/typesexport outside this card's file surface.The action path from the repro (
POST /api/v1/actions/crm_quote/print_quote) produces no sentence of its own for these failures: the/actionsdoor forwards a same-origintype: 'api'action in-process withaccept-languageon its header allowlist (API_FORWARD_HEADER_ALLOWLIST,packages/runtime/src/action-execution.ts) and relays the target's refusal envelope with itsmessageas written (restAnswerOf,forward-refused,packages/runtime/src/action-dispatch.ts). So fixing the door fixes the action toast; nothing changed inpackages/runtime.Bounded in-place fix, declared: the caller-resolution 500 (
The caller of this print could not be resolved.) is the same door's own 5xx sentence, the same defect class, the same file in the claim's surface, the same gate family; it is localized the same way and pinned below.Read first
packages/services/service-print/src/print-routes.ts(therequestLocaleOf/serverAnswerKeyFor/serverAnswerForhunk) — the only behaviour change.packages/spec/src/system/operation-message.ts— the 16 new catalog strings; the zh-CN, ja-JP and es-ES wording is the review risk.packages/services/service-print/src/print-routes.test.ts— the new top-leveldescribe.Two-minute verification
pnpm --filter @objectstack/service-print exec vitest run --maxWorkers=2 src/print-routes.test.ts— expect 36 passed, including ten under "its own 5xx sentences, in the request's language".Tests
All at head
3dfbfdb5a.pnpm --filter @objectstack/service-print test— Test Files 9 passed (9), Tests 145 passed (145).pnpm --filter @objectstack/spec test— Test Files 891 passed (891), Tests 28371 passed, 1 todo.pnpm --filter @objectstack/service-print typecheckexit 0;pnpm --filter @objectstack/spec typecheckexit 0 (tsc, scripts and test typecheck).print-routes.test.ts): 503, 504 and 500 underaccept-language: zh-CN,zh;q=0.9,en;q=0.8answer the zh-CN catalog sentence and not the English one; the control:en-USand an absent header answer the English sentence, for each of the three; the English sentences equal the pre-change text;jareaches ja-JP andde-DEfalls back to English; the caller-resolution 500 in zh-CN and absent; a 4xx keeps its producer's text under zh-CN.operation-message.test.ts): all four keys in every locale, placeholder-free, naming no wire code or host vocabulary, distinct from every other key, rendering zh-CN / es / en fallback.Ablation: hard-coded English restored, zh pins turn red
node scripts/ablation-replace.mjsonprint-routes.ts, anchorreturn operationUserMessage(serverAnswerKeyFor(status), { locale });replaced with the three original hard-coded English returns. The test imports the subject by relative path and aliases core/spec to source, so no build stands between the mutation and the run.The three English controls stayed green under the mutation, as they should.
Gates
node scripts/pm/dispatch-gates.mjs --commandsderived 91 families for this diff; all 91 were run at3dfbfdb5a, each exit captured before any pipe. Reconciliation (--ranwith exit codes):✓ 91 derived famil(ies) accounted for — 88 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3).node scripts/check-plugin-teardown-shape.mjs --self-test, reason: shallow clone cannot reach its pinned positive-control commit.pnpm check:dual-build-cjs-loads, reason: reads every package's built output; only the service-print closure was built here.pnpm check:type-check-debt, reason: its re-measure queued on the shared verify lock behind a long dogfood run (exit 99 twice).All three run in CI on this PR.
test:repowas not run locally (no diff in that project); declared to CI'sTest Core.Acceptance notes
Accept-Languageonly. The door's execution context carries no locale and no workspace default (requestLocale: undefined,localization: undefined), sooperationUserMessage's second rung (the workspace default) has nothing to read here; the console sends its UI language on every call, which is the issue's case.errors.print_*translation override is consulted:operationUserMessageis the helper for producers that hold no i18n service, and the door holds none./actionsdoor's own forward-unavailable sentence (apiActionForwardUnavailableError, 503) and the print bridge's501are English too; neither is on this card's path when the door is mounted, and neither was reproduced here.Recordvalue, and the wiremessagechanges language only for a non-English request.Generated by Claude Code