Repository navigation
fix(agent): refuse a single-record action given several records [PRD-1704] - #337
Open
hercemer42 wants to merge 3 commits into
Open
hercemer42 wants to merge 3 commits into
hercemer42 wants to merge 3 commits into
Conversation
…1704] A single-record action triggered on several ids ran on the first record only and answered success, since ActionContextSingle.get_record reads the first record. An API client, an MCP call or an approval request could send such a selection, and every record past the first was silently skipped. The action resource now answers 422 for a single-record action whose selection names more than one id or is a select-all, before the permission check: no approval is asked for, approving a stored request runs nothing, and the form hooks refuse it too. Same fix as the Node agent (ForestAdmin/agent-nodejs#2028). Refs: PRD-1704 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hercemer42
commented
Oct 21, 2026
hercemer42
left a comment
Author
There was a problem hiding this comment.
Spec (PRD-1704): conforms.
| from forestadmin.agent_toolkit.utils.id import unpack_id | ||
| from forestadmin.datasource_toolkit.decorators.action.result_builder import ResultBuilder | ||
| from forestadmin.datasource_toolkit.exceptions import BusinessError | ||
| from forestadmin.datasource_toolkit.exceptions import BusinessError, UnprocessableError |
Author
There was a problem hiding this comment.
Claude Opus 5.5 (claude-opus-5-5): There is additional feedback on https://linear.app/forestadmin/issue/PRD-1704, so please read it before merging.
An empty selection leaves the action's filter unrestricted, so a single-record action sent `ids: []` ran on whichever record it read first. The single-record guard now refuses anything but exactly one id. Refs: PRD-1704 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs: PRD-1704 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A single-record action triggered on several record ids now answers 422 ("This action can only be triggered on one record at a time.") instead of running on the first record and answering success. Same fix as the Node agent (ForestAdmin/agent-nodejs#2028) and the Ruby agent (ForestAdmin/agent-ruby#417).
Refs: PRD-1704
What changes
ActionContextSingle.get_recordreturnsrecords[0]) and answered success, so the other records were skipped and nobody was told. After: 422, and nothing runs./hooks/load,/hooks/change,/hooks/search). Before: the form loaded against the first record. After: 422.A single-record action on exactly one id, and bulk and global actions, behave as before; a test now pins the one-id case.
Squash message
🤖 Generated with Claude Code
Note
Refuse multi-record selections on SINGLE-scope actions in
ActionResourceActionResource._get_records_selectionnow validates the record selection for SINGLE-scope actions and raisesUnprocessableErrorunless exactly one ID is selected. This rejects empty selections, multi-ID selections, select-all selections, and selections with excluded IDs, before permission checks and form computation. Signed approval data with multiple IDs is also rejected. Adds a full test fixture in test_resources.py covering rejection cases and the single-ID success path.UnprocessableErrorinsrc/agent_toolkit/forestadmin/agent_toolkit/resources/actions/resources.pyMacroscope summarized b394193.