Repository navigation
fix(runtime)!: the flow trigger door refuses a params that is not a JSON object - #25974
Conversation
…(red) Claude-Session: https://claude.ai/code/session_01Ny9nEFwaZEjuu6xpu6Y4gC Co-authored-by: Claude <noreply@anthropic.com>
…ject Claude-Session: https://claude.ai/code/session_01Ny9nEFwaZEjuu6xpu6Y4gC Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ny9nEFwaZEjuu6xpu6Y4gC Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ny9nEFwaZEjuu6xpu6Y4gC Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 6 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
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 3823beb0dfabe1b5508653d832e1789f4a93e697 && git checkout 3823beb0dfabe1b5508653d832e1789f4a93e697
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin cdd4eea93811522cca145a0f24858def51443671 7f0c45b48d2f72e049c3ce4039c0552d0021ed43 && git checkout -B drift-repro cdd4eea93811522cca145a0f24858def51443671 && git merge --no-ff 7f0c45b48d2f72e049c3ce4039c0552d0021ed43
node scripts/docs-audit/affected-docs.mjs --json cdd4eea93811522cca145a0f24858def51443671
|
Contract reviewServed-tier: Inputs: card #25821 body and its three comments (triage 6399814705, claim 6409382263, os-dev-report 6410469534); PR #25974 body, file list and the net diff ① Derived judgmentsCI on the head is still in progress at review time. 50 check-runs: 25 a. Which b. Refusing c. Accepted shapes are byte-identical — right. d. The resume door is byte-identical after the hoist — right. On e. The refusal body is the ruled one, before dispatch, no run row — right. f. Public surface. No published schema moves: the spec's trigger route ( g. Test shape. The new suite drives the real ② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS Generated by Claude Code |
席位核对 · ACCEPT ·
|
| item | reading |
|---|---|
| Shape | draft, base main, Fixes #25821, Clause-②: no (narrowing: …) and Metadata-protocol: none line-initial in body and changeset, patch with the BREAKING banner. The claim said Clause-②: no; the dev measured a narrowing and declared it, accepted. |
| Files (3, +284/−13) | runtime/src/domains/automation.ts (one shape check objectValueFailure, hoisted from the resume door's #9416 loop and shared by both doors), one new suite, one changeset. No packages/spec/**, not governed (check-governed-merges --pr 25974), 297 changed lines. |
| Fix | a non-object params (string, number, boolean, array, null) on both trigger spellings and every declared type: 'flow' endpoint answers 400 VALIDATION_FAILED with fields[0] = { params, invalid_type }, before execute(), no run row; absent params keeps the empty bag; 404/403 still come first. Refusing null matches the resume door on main. |
| Evidence | red first 29/42 on base; ablation 29 red; runtime 7224 tests + typecheck green; 69/69 derived gates exit 0; live boot shows 400 and no run row (report). |
| Carried | the two class-a findings (the action door's own params guard; a non-object trigger body) are out of this card and carried by the seat. |
| Landing | ready + auto-merge through the relay once every check on this head is green or an expected skip. |
Generated by Claude Code
Requested by Leehom · project thread
Fixes #25821
Clause-②: no (narrowing)
Metadata-protocol: none
Contract review owed: the
(narrowing)arm. The trigger doors refuse request shapes they used to dispatch, aparamsthat is a string, number, boolean, array ornull. Nothing is widened, and nopackages/spec/**path is touched. The seat's claim (6409382263) carriesClause-②: no; the line above is the measured value on this diff, declared as the dispatch order asked.What changed
buildAutomationContext(packages/runtime/src/domains/automation.ts) readparamswithparams && typeof params === 'object' ? { ...params } : {}. A string became an empty bag and the flow ran with no inputs. An array was spread into an index-keyed bag. A falsy value (null,0,false,"") took the flat-body branch, which forwarded the body's other top-level keys as params instead.The builder now refuses a
paramsthat is not a JSON object, before anything is dispatched:400 VALIDATION_FAILED, onefields[]entry{ field: 'params', code: 'invalid_type' }, messageInvalid trigger body — params expected an object (a map of names to values), received a string(the received type varies). It is thrown as the validation failure both dispatcher exits and the endpoint executor already answer as 400.The check is one function,
objectValueFailure(field, value), hoisted out of the resume door's #9416 value-shape loop. The resume door now calls it forinputs,variablesandoutputand the trigger door calls it forparams, so the two doors of one engine ask the same question in the same words. The resume answers are byte-identical (its suites pass unchanged). The resume arm's localjsonTypeOfstays local, as its note asks; only this one refusal is shared.undefinedcounts as absent, as on the resume door, so a body with noparamskey still takes the flat-body branch. An explicitnullis refused, as the resume door refuses{"inputs":null}.Doors measured
POST /api/v1/automation/:name/triggerrespondToFlowTriggerPOST /api/v1/automation/trigger/:name(legacy,client.automation.trigger())type: 'flow'API endpoint (endpoint-executor.tsexecuteFlow)POST /api/v1/actions/:object/:actionon atype: 'flow'actionreqBody.paramsitself (domains/actions.ts)subflow,mapnodes)engine.executewith a built contextverifycallsexecutein processOrder on the REST doors and the endpoint: an unknown flow still answers
404and a caller the flow refuses still answers403, before the body is judged. The refusal is beforeexecute(), so no run starts and no run row is written.Evidence
Live, fresh showcase boot (
pnpm dev -- --fresh) on this branch at7f0c45b4, signed in as the seeded admin:POST /api/v1/automation/showcase_notify_owner/triggerandPOST /api/v1/automation/trigger/showcase_notify_owner, each with{"params":"oops"},{"params":[1,2]},{"params":null,"ownerId":"u1"}and{"params":42}: all eight answer400 VALIDATION_FAILEDnamingparamswith the received type.{"params":{}}on both routes still dispatches (400 FLOW_FAILED, "Unknown variable: ownerId", the flow's own answer with no inputs).GET /api/v1/automation/showcase_notify_owner/runsafterwards lists 2 runs, the two controls. The eight refused requests left no run row.POST /api/v1/apps/showcase/inquiries/purge(a declaredtype: 'flow'endpoint) with{"params":"oops"}:400 VALIDATION_FAILEDnamingparams.Tests (
packages/runtime/src/domains/automation-trigger-params-shape.test.ts, new, 42 cases):automation.tsrestored from base9ca36b16, 29 failed / 13 passed (every refusal case red, every preservation case green).scripts/ablation-replace.mjs,if (paramsFailure) {toif (paramsFailure && false) {, anchor 1 to 0, blob moved, restored to the HEAD blob withgit diff HEADempty): 29 failed / 13 passed.pnpm --filter @objectstack/runtime typecheck && pnpm --filter @objectstack/runtime testat7f0c45b4: lock VERDICT command-exit 0, 448 test files passed, 7224 tests passed, 19 skipped.Gates at
7f0c45b4:node scripts/pm/dispatch-gates.mjs --commandsderived 69 families; all 69 exit 0 (three needed the full build or an unshallow fetch first and were rerun after it).--ranreconciliation: 69 derived, 69 run, 0 NOT-MEASURED.eslint --no-inline-config packages/runtime: exit 0. Fullpnpm turbo run build: 121/121 tasks.Dogfood battery (the
(narrowing)arm), full, at7f0c45b4:pnpm --filter @objectstack/dogfood testunder the lock, VERDICT command-exit 0, Test Files 296 passed / 3 skipped (299), Tests 2523 passed / 18 skipped (2541), no failures.origin/mainmoved after the merge (10 commits, none touchingdomains/automation.ts,endpoint-executor.tsorhttp-dispatcher.ts;git merge-treeclean), so this head is not re-merged; CI runs on the merge ref.Acceptance notes
Two sibling doors drop a non-object value the same way. Neither shares the builder, so neither is touched here; both are reported to the seat with their live readings.
POST /api/v1/actions/:object/:actionreadsparamswith the sameparams && typeof params === 'object'guard (domains/actions.ts). On the fresh boot,POST /api/v1/actions/showcase_task/showcase_bulk_reassignwith{"params":"oops"}and with{"params":[1,2]}each answered200and started a paused run, exactly as{"params":{}}did.ctxBody = body && typeof body === 'object' ? body : {}. A JSON string body"oops"dispatchedshowcase_notify_ownerwith an empty bag (400 FLOW_FAILED, "Unknown variable: ownerId"), and an array body[1,2]forwarded its indices as params. The resume door refuses a non-object body; the trigger ruling coversparamsonly.Generated by Claude Code