feat(spec): reject a body on a non-script action — it would never run (#3530) - #3548
Merged
Merged
Conversation
…un (#3530) `Action.body` is documented as "only meaningful when `type === 'script'`", but nothing enforced it. A `type: 'modal'` action authored with `params` and a `body` — expecting the modal to collect the input and the body to write the record on submit — passed validation, passed shape tests, and shipped a button that opened a modal and silently wrote nothing. Non-script types all dispatch on `target` (the page to open, the URL, the flow, the endpoint); there is no point at which a renderer would invoke the body. This is the same invisible-failure shape as the existing rule that rejects a `script` action with neither `body` nor `target` (#2169), so it is enforced the same way: a parse-time error that names the fix — `type: 'script'` collects the same `params` and does run the body, and a modal that only opens a page should drop the `body` and keep `target` naming the page. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KYuc9N6YRbvoDMbCvJiX9f
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 104 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
…arget` resolves Keeps the two action docs in sync with the parse-time rule added in this PR (and with the console-side target resolution in objectui#2826): - ui/actions: a second "trap" callout next to the existing dead-button one — a `body` on a non-script action is rejected, with `type: 'script'` + `params` named as the shape for "collect input, then run logic". - protocol/objectui/actions: `body` on a non-script type is now a parse-time error, not just "not meaningful"; the Modal Actions section states the page → object → server-handler resolution order and that `params` are collected before the target opens. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KYuc9N6YRbvoDMbCvJiX9f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3530. The console-side half is objectstack-ai/objectui#2826.
The authoring trap
The action in #3530 is declared like this:
The author's expectation — stated in the issue's Expected section — is that the modal collects the params and then "the action body executes with the collected
input, and the record is written".It never does.
Action.bodyis documented as "Only meaningful whentype === 'script'", and every non-script type dispatches ontargetinstead (the page to open, the URL, the flow, the endpoint). There is no point at which a renderer would invoke the body. Nothing enforced that documented constraint, so the action passed validation, passed shape tests, and shipped a button that opens a modal and silently writes nothing.Change
Added a parse-time refine rejecting
bodyon any non-scriptaction.This is deliberately the same shape as the rule directly above it, which rejects a
scriptaction carrying neitherbodynortarget(#2169 — "Mark Done does nothing"). Both catch the same class of defect: an action that validates, builds, and then no-ops at runtime, where the failure is invisible to every automated check and only surfaces as a user reporting that a button does nothing. The message names the fix rather than just the violation:type: 'script'is the working shape for the reporter's intent: it collects the sameparamsthrough the same dialog, then POSTs to/api/v1/actions/{object}/{name}, where the registered body runs with the collected input.Compatibility
No action in this repo pairs a body with a non-script type — I scanned both repos before adding the rule, and the
app-showcaseandapp-todobundles both build clean against it.Testing
modal,url,flow,api,form), and the corrected authoring from the issue (a modal action withparamsand nobody) still parses.packages/specfull suite: 258 files / 6842 tests pass.packages/runtime(635 tests) andpackages/objectql(1081 tests) pass.@objectstack/example-showcaseand@objectstack/example-todobuild clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01KYuc9N6YRbvoDMbCvJiX9f
Generated by Claude Code