Skip to content

fix: prevent null crash in debugTogglePlatform when vmService is null#185812

Merged
auto-submit[bot] merged 11 commits into
flutter:masterfrom
briskbase-projects:fix/debug-toggle-platform-null-check
May 4, 2026
Merged

fix: prevent null crash in debugTogglePlatform when vmService is null#185812
auto-submit[bot] merged 11 commits into
flutter:masterfrom
briskbase-projects:fix/debug-toggle-platform-null-check

Conversation

@briskbase-projects

@briskbase-projects briskbase-projects commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

When running flutter run -d web-server, pressing the 'o' key to toggle platform caused a null check crash because vmService is null for web-server devices.

Added a null guard that returns early with an informative message instead of crashing the tools process.

Fixes #185766

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

When running flutter run -d web-server, pressing the 'o' key to toggle
platform caused a null check crash because vmService is null for
web-server devices.

Added a null guard that returns early with an informative message
instead of crashing the tools process.

Fixes flutter#185766
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla

google-cla Bot commented Apr 30, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a safety check in resident_runner.dart to prevent crashes when flutterDevices is empty or the vmService is null during a platform toggle. The review feedback identifies a redundant null-aware operator and requests the addition of a test case to verify the fix, as required by the repository's style guide.

Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
@bkonyi bkonyi added the CICD Run CI/CD label Apr 30, 2026
@bkonyi bkonyi requested review from bkonyi and chingjun April 30, 2026 14:48
chingjun
chingjun previously approved these changes Apr 30, 2026

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, but we'll need to fix the analysis failures first before we can land.

Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
@briskbase-projects

Copy link
Copy Markdown
Contributor Author

Hi @bkonyi, I've addressed your feedback:

  • Removed the unnecessary doc comment
  • Ran dart format and dart analyze locally — no issues found

Latest changes have been pushed. Please let me know if anything else needs to be addressed.

Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
Comment thread packages/flutter_tools/test/general.shard/terminal_handler_test.dart Outdated
Comment thread packages/flutter_tools/lib/src/resident_runner.dart Outdated
navaronbracke
navaronbracke previously approved these changes May 1, 2026
@bkonyi bkonyi added the CICD Run CI/CD label May 1, 2026
bkonyi
bkonyi previously approved these changes May 1, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label May 1, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 1, 2026
@auto-submit

auto-submit Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/185812, because - The status or check suite Linux analyzer_benchmark has failed. Please fix the issues identified (or deflake) before re-applying this label.

Comment thread packages/flutter_tools/test/general.shard/terminal_handler_test.dart Outdated
…t.dart

Co-authored-by: Navaron Bracke <brackenavaron@gmail.com>
@briskbase-projects briskbase-projects dismissed stale reviews from bkonyi and navaronbracke via e25356c May 1, 2026 17:50
@github-actions github-actions Bot removed the CICD Run CI/CD label May 1, 2026
@bkonyi bkonyi added the CICD Run CI/CD label May 4, 2026

@navaronbracke navaronbracke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web-server] Pressing 'o' key crashes flutter tools with null check error in debugTogglePlatform

4 participants