Repository navigation
feat(rest): the cross-object batch refusal names the failing operation, and a multi-pick related-list add names that record - #35811
Conversation
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
…peration Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
…rd the server's refusal points at Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
…eration Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
📓 Docs Drift Check3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 19 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 d9e6d20f4a8e07a7f6fa9b4ab0f52c41151bc992 && git checkout d9e6d20f4a8e07a7f6fa9b4ab0f52c41151bc992
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7878cf0557737ecfde78dfa9cff7a1046a289a4a d6b03538fc4843e560c83ded2038f5c9fd938bc2 && git checkout -B drift-repro 7878cf0557737ecfde78dfa9cff7a1046a289a4a && git merge --no-ff d6b03538fc4843e560c83ded2038f5c9fd938bc2
node scripts/docs-audit/affected-docs.mjs --json 7878cf0557737ecfde78dfa9cff7a1046a289a4a |
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对ACCEPT · head Routing: Checked:
For the L2 (ux-2's two questions):
Required before landing:
No other item. |
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ Seat contract note — PASS · head
|
|
repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ Landing · area ux-2 · 2026-11-20T09:44Z
State: draft → ready + auto-merge (merge queue). |
Fixes #35726
Part of #35601
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
Server (
@objectstack/rest,batch-routes.ts). A refusal of the cross-objectPOST {basePath}/batchnow carriesfailedOperation: { index, object }besideerror/code/userMessagewhen ONE op is the cause:update/deleteop refused up front for naming no row (400 VALIDATION_FAILED, therequires an idrefusal);404 RECORD_NOT_FOUND,400 VALIDATION_FAILEDfrom a validation rule or a required field,409 RESOURCE_CONFLICT), an unresolved$ref(400 BATCH_UNRESOLVED_REF), or a fault.It is absent on a refusal of the request as a whole (schema
VALIDATION_FAILED,BATCH_NOT_ATOMIC,BATCH_TOO_LARGE, the501 NOT_IMPLEMENTEDno-transaction answers), on the two object-level gates (API exposure and the API-key management rule, judged once per object and action, so no single op is the cause), and on a failure after the last op ran (the commit). The in-transaction case goes through the shared error door unchanged (handleRouteError): a thin response wrapper adds the one key to the body the door wrote, so status, code, sentence anddetails.candidatesare the door's.Unchanged: the success body, the all-or-none outcome (ADR-0119 D4, ADR-0035 section 5), the
#14147option C create routing and the A-prime update-response comment blocks (no line in either was edited), every other route.Spec. No spec edit. The cross-object batch's refusal envelope is not declared in
packages/spec:CrossObjectBatchResponseSchemadeclares the success body only, the error-code ledger declares codes, not body keys, and the route ledger row named/batch(DEFAULT_BATCH_ROUTES) is the per-object/data/:object/batchdoor. Declaring a new refusal schema would be a new export, which this card did not rule on (see Acceptance notes).Client pass-through. No client edit.
@objectstack/clientalready hands a flat refusal body with nodetailsof its own over aserr.details, andObjectStackAdapter.batchTransactionrethrows that error as it is, so the key reaches the console aserr.details.failedOperation.Console (
@object-ui/plugin-detail,RelatedList.tsxhandleAddRecordsonly). The add keeps the picked record behind each op, index-aligned with the ops it sends (a pick with no value is skipped, so pick index and op index can differ). On a refusal whosefailedOperation.indexfalls inside the ops sent, the inline error readsLABEL: REASON, where LABEL is the record's value in the picker's display field (add.picker.labelField, elsename, as the picker shows it; the picked id when that is empty) and REASON is today's message. Without such an index the inline error is the server's reason alone, as before.Why
PR #35725 made a multi-pick related-list add one atomic batch: all rows or none. Its refusal then repeated the server's sentence, which names the record for a not-found or permission refusal but only the field for a validation refusal, so a reader of a three-pick add could not tell which pick failed.
Tests
packages/rest/src/cross-object-batch-failed-operation.test.ts(new, realObjectQL+ SQLiteSqlDriver+ real protocol + real route): 3 ops whose 2nd addresses no row answers404 RECORD_NOT_FOUNDwithfailedOperation: { index: 1, object: 'fop_beta' }and both tables empty; 3 ops whose 2nd misses a required field answers400 VALIDATION_FAILEDwith index 1 and both tables empty. CONTROLS: a committing 3-op batch has nofailedOperation;atomic: false(BATCH_NOT_ATOMIC) names no op. The route has no non-atomic run to pin:atomic: falseis refused before any op runs.packages/rest/src/rest-batch-blank-id.test.ts: the exact-body pins of the missing-id refusal now carryfailedOperation, index 0 for a one-op batch and index 1 for the create-then-blank-update batch.packages/rest/src/rest-batch-endpoint.test.ts: the package-scoped409exact-body pins carryfailedOperation: { index: 0, object: 'account' }besidedetails.candidates.ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx: a 3-pick add whose refusal names op 1 showsBravo: Field 'title' is required(not Alpha, not Charlie), sends one batch and does not re-read the list. CONTROLS: nofailedOperation, and an index outside the ops sent, each show the server message alone.Every reading below was taken in this worktree on
objectstack-ai/objectstack, branch base1e018d6ed.rest: targeted batch files, full package suite, typecheck
pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2over the six cross-object batch files (new file, blank-id, no-rollback driver, exposure, API-key credential, request refusal fields):Test Files 6 passed (6),Tests 49 passed (49), lockVERDICT command-exit 0.vitest run --project local --maxWorkers=2atc6fe2c39(before the package-scoped pins were updated):Test Files 1 failed | 422 passed (423),Tests 9 failed | 8623 passed | 351 skipped; the 9 were exactly the package-scoped exact-body pins inrest-batch-endpoint.test.ts, which this PR updates. After the update:rest-batch-endpoint+ new file + blank-idTest Files 3 passed (3),Tests 56 passed (56).d6b03538,vitest run --project local --maxWorkers=2:Test Files 423 passed (423),Tests 8632 passed | 351 skipped (8983), lockVERDICT command-exit 0.pnpm --filter @objectstack/rest typecheck(tsc +check:test-typecheck):VERDICT command-exit 0,0 file(s) / 0 error(s)in the test-typecheck debt.plugin-detail: target file, full package, type-check
pnpm --dir ui exec vitest run --maxWorkers=1 packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx:Test Files 1 passed (1),Tests 16 passed (16)(13 before, 3 new).pnpm --dir ui exec vitest run --maxWorkers=1 packages/plugin-detail/:Test Files 391 passed | 1 skipped (392),Tests 3568 passed | 18 skipped (3586), lockVERDICT command-exit 0.pnpm --filter @object-ui/plugin-detail type-check(after building its dependency closure):VERDICT command-exit 0.Ablations (scripts/ablation-replace.mjs, one per pin, each restored)
Both subjects resolve from source (the rest test imports
./rest-server, the UI test imports../RelatedList), so nodist/leg applies.failedOperation = { index, object: op.object };replaced with a comment,anchor 1 -> 0, blobf321bb114e1e -> c9a261104266. Run:Tests 2 failed | 2 passed (4), the two index-1 cases red, both controls green. Restore:blob == HEAD (f321bb114e1e) and git diff HEAD is empty.const failedIndex = err?.details?.failedOperation?.index;replaced withconst failedIndex: unknown = undefined;, blobacdaba8815ce -> 11bd61acb2ea. Run:Tests 1 failed | 15 passed (16), the naming case red, both controls green. Restore:blob == HEAD (acdaba8815ce) and git diff HEAD is empty.Gates (dispatch-gates --commands, narrowed by this diff)
node scripts/check-plugin-teardown-shape.mjs --self-test(the shallow clone cannot reach its pinned positive-control commit) andpnpm check:dual-build-cjs-loads(reads built output of every package; this worktree built only the two closures). CI runs both.pnpm check:route-envelopeexit 0 (the batch module's dialect counts did not move),pnpm check:doc-authoringexit 0,pnpm check:type-check-debtexit 0,pnpm --dir ui exec vitest run scripts/Tests 5092 passed | 2 skipped.dispatch-gates --ranreconciliation:72 derived, 70 run, 2 NOT-MEASURED, 0 UNRUN(the 2 derived from a recorded exit 3).node scripts/check-platform-checklist.mjs --changed-from origin/main: OK, 0 anchors lost.check-nul-bytesexit 0.Acceptance notes
405/403 OBJECT_API_DISABLED, the API-key management403) carry nofailedOperation. They are judged once per object and action, so naming the first op would make the related-list add name one picked record for a refusal that holds for every pick; andbatch-op-exposure-object-read.test.tspins the exposure body equal to the bulk data door's.details(the package-scoped409withdetails.candidates) keepsfailedOperationon the body, but@objectstack/clientexposes only thatdetailsaserr.details, so the console shows the reason alone there. Reaching it would take a client-side read of the raw body, which the client does not keep; not done here.packages/spec(see What changes). Declaring aCrossObjectBatchErrorSchemawould be a new public export and a contract decision, so it is reported, not done.ObjectStackAdapter.batchTransactionon a backend that does NOT declarecapabilities.transactionalBatchtreats a404as "no batch endpoint" and falls back to the non-atomic emulation, so on such a backend a404 RECORD_NOT_FOUNDrefusal is read as a missing endpoint and the ops are replayed through that emulation, which carries nofailedOperation. Documented legacy behaviour for pre-capability backends; not changed.origin/mainwas not merged before opening: it moved 187 files past the base, none of them a file this diff touches (batch-routes.ts, the three rest test files,RelatedList.tsx, its test). The PR CI runs on the merge ref.Verification
Read first, by risk:
packages/rest/src/batch-routes.ts:namingFailedOperationand the twofailedOperationassignments inrunOps(set per op, cleared after the loop).ui/packages/plugin-detail/src/RelatedList.tsx:handleAddRecords, theopPicksalignment and the catch block.packages/rest/src/cross-object-batch-failed-operation.test.ts.Two-minute check:
pnpm --filter @objectstack/rest exec vitest run src/cross-object-batch-failed-operation.test.tsprintsTests 4 passed (4).Human Minimum
packages/specholds no runtime logic.pnpm lintpasses. (No formatter ran;pnpm lintis CI's run.)main, one pull request. (Branched offmainat1e018d6ed; not re-merged before opening, see Acceptance notes.)packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code