Repository navigation
fix(runtime)!: the package draft doors refuse a query parameter they do not read - #26853
Conversation
…do not read `POST /packages/:id/publish-drafts?dryRun=true` ignored the parameter, published the drafts for real and answered 200 outcome "published"; the same parameter on `discard-drafts` dropped them. Both doors read no query parameter, so their closed set is empty: any name is now refused 400 VALIDATION_ERROR with the shared recognition sentence (`unknownQueryParamRefusalMessage`, @objectstack/rest), after the capability and wall gates and before the protocol is asked. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nX7RrMithjQTtAtVb
📓 Docs Drift CheckThis PR changes 1 package(s): 13 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 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 87f66943c44a702fb78a3fefa3f4228937ddde22 && git checkout 87f66943c44a702fb78a3fefa3f4228937ddde22
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8eef9a8db402b6d46b15cc2375f8acddbb0d7b7e e542b231bbdd4b25f98d44d2cad54c80b33cc228 && git checkout -B drift-repro 8eef9a8db402b6d46b15cc2375f8acddbb0d7b7e && git merge --no-ff e542b231bbdd4b25f98d44d2cad54c80b33cc228
node scripts/docs-audit/affected-docs.mjs --json 8eef9a8db402b6d46b15cc2375f8acddbb0d7b7e
|
席位核对ACCEPT · The maintainer's standing authorisation for landing reviewed PRs, verbatim: 「按照 pm-dispatch 规则复核过的都授权」.
Generated by Claude Code |
Requested by Leehom · project thread
Fixes #26713
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill or doc teaches a query parameter on either draft door:
skills/**andcontent/docsnamepublish-drafts/discard-draftsonly inplugin-hooks.md,metadata-api.mdx(a route list) and two reference tables, none with a query string, and no caller inui/**,packages/client, the CLI orskills/**sends one.维护者速读
POST /packages/:id/publish-drafts与discard-drafts现在拒收任何查询参数,答400 VALIDATION_ERROR,文案用仓里唯一的那句「不认识的查询参数」。publish-drafts?dryRun=true以前忽略参数、真的发布草稿并答 200published;想预览的工具与 AI 拿到的是不可逆的发布。MetadataClient、SDK 都不带参数,行为不变。回滚即还原packages.ts一处 helper 与两行调用。packages/runtime/src/domains/packages.ts的refuseDraftDoorQuery与两处调用(在权限与 wall 闸之后、协议之前);其次新测试packages-draft-doors-closed-query.test.ts。cd packages/runtime && pnpm exec vitest run src/domains/packages-draft-doors-closed-query.test.ts,预期 10 passed;带?dryRun=true的两例答 400 且协议未被调用。What changes
packages/runtime/src/domains/packages.ts: the draft doors' closed query set is declared (DRAFT_DOOR_QUERY_PARAMS, measured EMPTY: both doors read the path id, the session and the body, never the query), andrefuseDraftDoorQueryanswers any name on the query string400 VALIDATION_ERRORwithunknownQueryParamRefusalMessagefrom@objectstack/rest, the recognition sentence every closed-query door answers, written throughdeps.errorwith the code the way the/metadoors write it (meta doors: the bundle-member selectormemberis dropped silently by the runtime dispatcher GET, by PUT, and by the by-name doors outside the ruling (no closed query sets); honour it or refuse it loudly #23072). No new sentence, no new code, no helper copied.requireManageMetadataandrefuseWalledCatalogPackageWrite, before the protocol is resolved, the hono adapter:createHonoApp's catch-all flattens a repeated query name to its last value, so every dispatcher arity rule is unreachable on a@objectstack/honohost #23214 placement on this domain's other write doors. A caller withoutmanage_metadatakeeps its403.discard-draftsis closed in the same change: it is the twin door the order names, reads no query either, and?dryRun=truethere dropped every pending draft. Its hunk is the same one call line.dryRun. A dry run would be a declared parameter and a protocol addition, which goes back to triage.dispatcher-plugin.tsmountPackagesRoute, and the@objectstack/honocatch-all into the samedispatch());RestServermounts neither (packages/rest/srchas no route for them), so there is one place to close.@objectstack/runtimepatch, with the BREAKING banner and the ADR-0087not-required (no-migration-prescription)disposition.Why
The QA run (S3) measured
POST /api/v1/packages/:id/publish-drafts?dryRun=truewith{}answering200 outcome: "published"with the draft live. A caller asking for a preview got the irreversible act, shaped like a success. Triage6446824931ruled: close the query set and refuse an unknown parameter with 400.Tests
packages/runtime/src/domains/packages-draft-doors-closed-query.test.ts, 10 cases, drivingdispatch()over a realSchemaRegistryand a recording protocol, for each door:{dryRun: 'true'}, a repeateddryRun, and two unknown names each answer 400VALIDATION_ERRORwith exactlyunknownQueryParamRefusalMessage(query, []), every name quoted, and the protocol'spublishPackageDrafts/discardPackageDraftsnever called;manage_metadatasending?dryRun=truegets 403, protocol not called.There is no declared flag on either door, so the order's "repeated declared flag still refused the #23214 way" has nothing to pin here; a repeated unknown name is answered by recognition, which runs first (the
query-allowlist.tsrule).Red first on base c8583f8, green on head, ablation
c8583f80(implementation absent): the new file 6 failed | 4 passed (expected 400, got {"status":200,..."outcome":"published"...}and the discard twindiscardedCount: 1).ObjectStackProtocolImplementationover SQLite, one pending view draft,handlePackages('/com.example.repairs/publish-drafts', 'POST', {}, {dryRun:'true'})):{"status":200,"code":null,"outcome":"published","draftsBefore":["view/repairs_board"],"draftsAfter":[],"servedLabel":"Board v1"}: the draft went live.{"status":400,"code":"VALIDATION_ERROR","message":"The \"dryRun\" query parameter is not supported by this endpoint. ... This endpoint takes no query parameters.","draftsBefore":["view/repairs_board"],"draftsAfter":["view/repairs_board"],"servedLabel":null}: nothing published, the draft still pending.e542b231throughscripts/ablation-replace.mjs(anchorif (message === undefined) return null;→... || true ..., anchor 1 → 0, blob8dcfe74db65c→f592f4389363): 6 failed | 4 passed, exactly the six refusal cases; restored blob == HEAD,git diff HEADempty. The test imports the dispatcher fromsrc, so no build sits between the mutation and the run.Acceptance notes
Sibling package write doors, measured on
c8583f80(none of them is changed here):POST /meta/:type/:name/publish(per-item publish,RestServer)META_ITEM_PUBLISH_PARAMS(#22877)POST /packages(install), readsoverwriteDELETE /packages/:id(uninstall), readskeepDataPATCH /packages/:id,PATCH /:id/enable,PATCH /:id/disable,POST /:id/publish,/:id/revert,/:id/rollback,/:id/commits/:c/revert,/:id/adopt-orphans,/:id/duplicatePOST /packages/publish(RestServerpackage route)Measured at the dispatcher door with the
packages-write-flag-arityharness:DELETE /packages/:id?keepdata=true(and?keep_data=true) answers 200 and callsdeletePackage({ packageId })with nokeepData, so the protocol drops the object tables the caller asked to keep. That is reported to the seat as a proposed card, not widened into this PR.Verification
All on head
e542b231(basec8583f80).pnpm --filter @objectstack/runtime test: Test Files 460 passed (460), Tests 7458 passed | 19 skipped; lock VERDICT command-exit 0.pnpm --filter @objectstack/runtime typecheck: exit 0.eslint packages/runtime --no-inline-configexit 0 (the repo-widepnpm lintis CI's).node scripts/pm/dispatch-gates.mjs --commandson this diff named 60 families; all 60 ran and exited 0;--ranreconciliation:60 derived famil(ies) accounted for — 60 run, 0 NOT-MEASURED. Two first-pass exit 3s were container prerequisites, re-run after fixing them:check-plugin-teardown-shape.mjs --self-test(positive-control commit fetched) andcheck:dual-build-cjs-loads(the seven packages withoutdist/built: 112 entries across 69 packages load).check-commit-card-trailers.mjs --range origin/main..HEADexit 0,check-nul-bytes.mjsexit 0.(narrowing)arm),pnpm --filter @objectstack/dogfood testunder the lock after its^...closure build: Test Files 314 passed | 3 skipped (317), Tests 2609 passed | 20 skipped (2629); VERDICT command-exit 0.test:repo(vitestrepoproject): not run locally; the diff touches no repo-project test and the derived list does not name it; CI Test Core runs it.origin/main8eef9a8d:git merge-treeclean; no open PR for metadata: the save door and the package publish door accept a package id that is not installed (object, dashboard, page …), storing and even publishing items into a phantom package; Studio renders a writable builder for it #26708 when this was opened.Human Minimum
packages/specholds no runtime logic. (No spec change.)pnpm lintpasses (scoped topackages/runtime, exit 0; the full sweep is CI's).main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Written by an os-dev card thread in session
session_01FEkQ5nX7RrMithjQTtAtVb, dispatched by the PM loop (server seat 2).🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5nX7RrMithjQTtAtVb
Generated by Claude Code