fix(action): restore page apiMap after executeAction completes#2275
Merged
Conversation
Reusable actions merge scoped API definitions into the shared page apiMap via createChildScope, but never removed them when the action finished. That let action-internal APIs remain callable from the rest of the screen and could permanently override page-level APIs with the same name. Snapshot affected keys before prepareScope and restore them in a finally block so scoped APIs are only visible while the action runs. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.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.
Bug and impact
Trigger: A screen calls
executeActionfor a reusable action that defines a scopedAPI:block (app-level or page-level). The action’s APIs share a name with an existing page API, or introduce APIs that should only exist inside the action.Impact: Action-scoped APIs were merged into the shared
pageData.apiMapand never removed when the action finished. After oneexecuteActioncall, any other control on the same screen couldinvokeAPIthose action-internal endpoints for the rest of the page lifetime. Colliding names permanently overwrote the page’s API definition, causing wrong endpoints/data on subsequent calls.Root cause
ActionScopeUtil.prepareScope()callscreateChildScope(mergedApiMap: ...), whichaddAlls into the page-levelapiMapshared by every scope on the screen.ExecuteActionActiondid not restore those entries afterexecuteActionWithScopereturned.Fix
prepareScopemerges action APIs.finallyblock so scoped APIs are only visible while the action runs (matchingdocs/reusable-actions.md).modules/ensemble/test/action_scope_api_restore_test.dart.Validation
modules/ensemble:flutter test test/action_scope_api_restore_test.dartDuplicate check
cursor/critical-bug-remediation-5d4b): Firestore listen dedup — different code path.executeActionapiMap persistence.