fix(wifi, action): correct callback routing and async apiMap restore#2286
Draft
cursor[bot] wants to merge 2 commits into
Draft
fix(wifi, action): correct callback routing and async apiMap restore#2286cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
When connectToWifi succeeded but onSuccess was omitted, _handleWifiResult still invoked onError because the error branch had no guard on result. IoT provisioning flows that only define onError would navigate to failure screens despite a successful WiFi join. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
The finally block in ExecuteActionAction ran as soon as the inner Future was returned, not when async work finished. Scoped APIs were removed before invokeAPI and other async body actions could run, causing crashes or wrong endpoints for reusable actions with async bodies. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
This was referenced Jun 17, 2026
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.
Description
Fixes two critical correctness bugs found in recent commits: WiFi provisioning incorrectly firing error handlers on success, and reusable actions restoring scoped APIs before async body work completes.
Bug 1: WiFi
onErrorfires after successful connectTrigger: A
connectToWifiaction succeeds (result == true) but only definesonError(noonSuccess) — a common IoT provisioning pattern.Impact: The app navigates to failure screens or shows error UI despite a successful WiFi join, causing provisioning retries, confused device state, and significant user-facing breakage.
Root cause:
_handleWifiResultinvokedonErrorwhenever it was defined, without checking whetherresult == trueafter the success branch was skipped.Fix: Return early on
result == truewhenonSuccessis absent; only runonErrorforfalse/nullresults.Bug 2:
executeActionapiMap restored before async body completesTrigger: A reusable action with a scoped
API:block runs an asyncbody(e.g.invokeAPI, nestedexecuteAction, navigation).Impact: Scoped API definitions are removed before the body finishes — causing
Unable to find api definitioncrashes or routing requests to wrong/restored page-level endpoints.Root cause: PR #2275 added snapshot/restore in a
finallyblock but returnedexecuteActionWithScopewithoutawait. In Dart,finallyruns when the Future is returned, not when it completes.Fix:
return await ScreenController().executeActionWithScope(...).Validation
modules/ensemble/test/wifi_action_test.dartforConnectToWifiActionYAML parsing.modules/ensemble/test/action_scope_api_restore_test.dartwith async finally timing tests documenting the await requirement.modules/ensemble:flutter test test/wifi_action_test.dartflutter test test/action_scope_api_restore_test.dartDuplicate check
cursor/critical-bug-remediation-7f90): CDNlastUpdatedAtpremature commit — different code path.cursor/critical-bug-remediation-5d4b): Firestore listen dedup — unrelated.cursor/critical-bug-remediation-32d4): added apiMap snapshot/restore but did not await async body — this PR completes that fix.connectToWifi— did not address success/error callback routing.Type of Change