Skip to content

fix(action): restore page apiMap after executeAction completes#2275

Merged
sharjeelyunus merged 1 commit into
mainfrom
cursor/critical-bug-remediation-32d4
Jun 14, 2026
Merged

fix(action): restore page apiMap after executeAction completes#2275
sharjeelyunus merged 1 commit into
mainfrom
cursor/critical-bug-remediation-32d4

Conversation

@cursor

@cursor cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

Bug and impact

Trigger: A screen calls executeAction for a reusable action that defines a scoped API: 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.apiMap and never removed when the action finished. After one executeAction call, any other control on the same screen could invokeAPI those 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() calls createChildScope(mergedApiMap: ...), which addAlls into the page-level apiMap shared by every scope on the screen. ExecuteActionAction did not restore those entries after executeActionWithScope returned.

Fix

  • Snapshot page-level API entries before prepareScope merges action APIs.
  • Restore the snapshot in a finally block so scoped APIs are only visible while the action runs (matching docs/reusable-actions.md).
  • Added modules/ensemble/test/action_scope_api_restore_test.dart.

Validation

  • Added unit tests for action-only removal, overwritten-name restoration, and prepare/restore round-trip.
  • Flutter SDK is not available on the automation runner; please run from modules/ensemble:
    flutter test test/action_scope_api_restore_test.dart

Duplicate check

Open in Web View Automation 

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>
@sharjeelyunus sharjeelyunus marked this pull request as ready for review June 14, 2026 21:59
@sharjeelyunus sharjeelyunus merged commit d179294 into main Jun 14, 2026
5 checks passed
@sharjeelyunus sharjeelyunus deleted the cursor/critical-bug-remediation-32d4 branch June 14, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants