Skip to content

[flutter_tools] Harden extension diagnostics models and RPC failure handling - #196233

Merged
auto-submit[bot] merged 11 commits into
flutter:masterfrom
bkonyi:ft-ext-diagnostics-model-fixes
Nov 23, 2026
Merged

auto-submit[bot] merged 11 commits into
flutter:masterfrom
bkonyi:ft-ext-diagnostics-model-fixes

Conversation

@bkonyi

@bkonyi bkonyi commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Previously, ValidationMessage omitted piiStrippedMessage from equality and skipped piiStrippedMessage and contextUrl validation in fromJson, ValidationResult exposed a mutable executionTime without value equality and defaulted missing or unknown type values to ValidationType.success in fromJson, ValidationResult.crash hardcoded https://github.com/flutter/flutter/issues in partner-facing package:flutter_tools_core, and DiagnosticsExtensionClient.runDiagnostics inherited the 5-second metadata RPC timeout while catching RPC and parse failures with printTrace and returning an empty list (which ExtensionDoctorValidator reported as [✓]).

This change marks ValidationMessage and ValidationResult as immutable final classes, includes all fields in == and hashCode, wraps ValidationResult.messages in List.unmodifiable, preserves pre-populated executionTime values in DoctorValidator.validate, enforces required fields and enum/type invariants in fromJson and ValidationResult.listFromJson, removes ValidationResult.crash in favor of DoctorValidator.createCrashResult so built-in validators preserve https://github.com/flutter/flutter/issues while ExtensionDoctorValidator attributes crashes and Doctor.doctorDuration timeouts to the extension package, and updates DiagnosticsExtensionClient.runDiagnostics to pass timeout: null, trace the failure naming connection.extensionName, and return an extension-attributed crash result on failure.

Output from Doctor.diagnose(verbose: false) with an ExtensionDoctorValidator wrapping a DiagnosticsExtension (my_test_extension) whose runDiagnostics throws a StateError:

Previous output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Crashing Diagnostic Check

• No issues found!

Current output:

Doctor summary (to see all details, run flutter doctor -v):
[☠] Crashing Diagnostic Check (the doctor check crashed)
    ✗ Due to an error in tool extension "my_test_extension", the doctor check did not complete. Please report this issue to the extension author.
    ✗ JSON-RPC error -32000: Bad state: Simulated extension diagnostics failure

! Doctor found issues in 1 category.

Part of #190755
Part of #190747

Pre-launch Checklist

…andling

Previously, `ValidationMessage` omitted `piiStrippedMessage` from equality and skipped `piiStrippedMessage` and `contextUrl` validation in `fromJson`, `ValidationResult` exposed a mutable `executionTime` without value equality and defaulted missing or unknown `type` values to `ValidationType.success` in `fromJson`, and `DiagnosticsExtensionClient.runDiagnostics` caught RPC and parse failures with `printTrace` and returned an empty list (which `ExtensionDoctorValidator` reported as `[✓]`).

This change marks `ValidationMessage` and `ValidationResult` as immutable `final` classes, includes all fields in `==` and `hashCode`, wraps `ValidationResult.messages` in `List.unmodifiable`, preserves pre-populated `executionTime` values in `DoctorValidator.validate`, enforces required fields and enum/type invariants in `fromJson` and `ValidationResult.listFromJson`, and updates `DiagnosticsExtensionClient.runDiagnostics` to log a warning naming `connection.extensionName` and return `ValidationResult.crash` on failure.

Previous output:
```text
Doctor summary (to see all details, run flutter doctor -v):
[✓] Crashing Diagnostic Check

• No issues found!
```

Current output:
```text
Failed to run diagnostics for extension "crashing_diagnostics_ext": JSON-RPC error -32000: Bad state: Simulated extension diagnostics failure
Doctor summary (to see all details, run flutter doctor -v):
[☠] Crashing Diagnostic Check (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues
    ✗ JSON-RPC error -32000: Bad state: Simulated extension diagnostics failure

! Doctor found issues in 1 category.
```

Part of flutter#190755
Part of flutter#190747
@bkonyi bkonyi added the CICD Run CI/CD label Nov 9, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 9, 2026
Previously, `ValidationResult.crash` in partner-facing `package:flutter_tools_core` hardcoded `https://github.com/flutter/flutter/issues`, and `DiagnosticsExtensionClient.runDiagnostics` inherited the 5-second metadata RPC timeout. Extension diagnostic failures and timeouts directed users to report third-party extension bugs on the Flutter SDK issue tracker, and legitimate extension checks taking longer than 5 seconds timed out before `Doctor.doctorDuration`.

This change removes the hardcoded issue tracker prompt from `ValidationResult.crash` in `package:flutter_tools_core`, adds `DoctorValidator.createCrashResult` on host `DoctorValidator` (preserving `https://github.com/flutter/flutter/issues` for built-in checks across `Doctor` and `GroupedValidator`), overrides `createCrashResult` on `ExtensionDoctorValidator`, and updates `DiagnosticsExtensionClient.runDiagnostics` to pass `timeout: null` and attribute failures to the extension package via `ExtensionDoctorValidator.createExtensionCrashResult`.

Previous output:
```text
Failed to run diagnostics for extension "my_test_extension": JSON-RPC error -32000: Bad state: Simulated extension diagnostics failure
Doctor summary (to see all details, run flutter doctor -v):
[☠] Crashing Diagnostic Check (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues
    ✗ JSON-RPC error -32000: Bad state: Simulated extension diagnostics failure

! Doctor found issues in 1 category.
```

Current output:
```text
Failed to run diagnostics for extension "my_test_extension": JSON-RPC error -32000: Bad state: Simulated extension diagnostics failure
Doctor summary (to see all details, run flutter doctor -v):
[☠] Crashing Diagnostic Check (the doctor check crashed)
    ✗ Due to an error in tool extension "my_test_extension", the doctor check did not complete. Please report this issue to the extension author.
    ✗ JSON-RPC error -32000: Bad state: Simulated extension diagnostics failure

! Doctor found issues in 1 category.
```

Part of flutter#190755
Part of flutter#190747
…nClient

Removes the `flutter#193955` heartbeat monitoring `TODO` comment in `DiagnosticsExtensionClient.runDiagnostics` per review feedback, as heartbeat monitoring is no longer planned.

Part of flutter#190755
Part of flutter#190747
@bkonyi
bkonyi marked this pull request as ready for review November 9, 2026 21:24

@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 refactors diagnostic validation crash handling and serialization in Flutter tools. It introduces custom crash result creation on DoctorValidator and ExtensionDoctorValidator to properly attribute crashes to specific tool extensions rather than the Flutter SDK. Additionally, ValidationMessage and ValidationResult are made immutable, with stricter JSON deserialization that throws FormatException on invalid or missing fields, and comprehensive unit tests are added to verify these behaviors. There are no review comments, and I have no additional feedback to provide.

chingjun
chingjun previously approved these changes Nov 11, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 11, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 11, 2026
@auto-submit

auto-submit Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

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

…s-model-fixes

# Conflicts:
#	packages/flutter_tools/lib/src/experimental/diagnostics.dart
#	packages/flutter_tools/test/general.shard/extension_protocol/diagnostics_service_test.dart
loic-sharma
loic-sharma previously approved these changes Nov 13, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo nits

Removes the unused `ValidationResult.crash` factory from `package:flutter_tools_core` now that host validators construct crash results via `DoctorValidator.createCrashResult` and `ExtensionDoctorValidator.createExtensionCrashResult`.

Logs caught RPC and deserialization failures in `DiagnosticsExtensionClient.runDiagnostics` via `Logger.printTrace` instead of `Logger.printWarning` so errors already surfaced in `ExtensionDoctorValidator.createExtensionCrashResult` are not printed twice.

Part of flutter#190755
Part of flutter#190747
Appends `(package:<extension_name>)` to `ExtensionDoctorValidator.title` when backed by a `DiagnosticsExtensionClient` so `flutter doctor` attributes custom diagnostic categories to their declaring extension package.

Sets a 60-second per-extension RPC timeout on `DiagnosticsExtensionClient.runDiagnostics` instead of `timeout: null` so hung extension diagnostics fail into an extension-attributed result without waiting for `Doctor.doctorDuration`.

Part of flutter#190755
Part of flutter#190747
@bkonyi bkonyi added the t: extensions Issues related to Flutter Tools extensions label Nov 18, 2026
Removes `executionTime` from `ValidationResult` in `package:flutter_tools_core` so the shared diagnostic model only carries wire-serializable validation state.

Simplifies `DoctorValidator.validate` to delegate directly to `validateImpl` and records elapsed validation time on host-side `ValidatorTask.executionTime` inside `Doctor.startValidatorTasks` via an injectable `StopwatchFactory`.

Part of flutter#190755
Part of flutter#190747
loic-sharma
loic-sharma previously approved these changes Nov 19, 2026

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-LGTM modulo nit

Extracts `Doctor._runValidator` as an `async` helper called from `Doctor.startValidatorTasks` using `await` and `try`/`finally` so the validation timeout `Timer` is cancelled and the `Stopwatch` is stopped when validation completes, throws, or times out.

Part of flutter#190755
Part of flutter#190747
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 23, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into flutter:master with commit d55b678 Nov 23, 2026
21 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 23, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 24, 2026
flutter/flutter@98744d3...b75c5b3

2026-11-24 [email protected] Roll Skia from 89e364b13f05 to 2140958ee284 (3 revisions) (flutter/flutter#197287)
2026-11-24 [email protected] Roll Skia from f82f3efc0461 to 89e364b13f05 (6 revisions) (flutter/flutter#197284)
2026-11-24 [email protected] Roll Dart SDK from 10aef26c73f5 to 87f515c52de9 (1 revision) (flutter/flutter#197279)
2026-11-24 [email protected] iOS: Drive platform view tests through IOSExternalViewEmbedder (flutter/flutter#197263)
2026-11-24 [email protected] Fix null check crash in flushSemantics from a stale ancestor geometry cache (flutter/flutter#192724)
2026-11-24 [email protected] [Impeller] Fix Windows build with MSVC 14.52: std::modf is [[nodiscard]] (flutter/flutter#193413)
2026-11-24 [email protected] [web] Preserve fill rules from path operations (flutter/flutter#195971)
2026-11-24 [email protected] Regenerate tool_test_durations.json (flutter/flutter#197261)
2026-11-24 [email protected] Roll Skia from 694af434cadd to f82f3efc0461 (4 revisions) (flutter/flutter#197258)
2026-11-24 [email protected] Increase number of 'Linux tool_integration_tests' subshards (flutter/flutter#197262)
2026-11-24 [email protected] Run tool_integration_tests app tests in one subshard instead of all of them (flutter/flutter#197264)
2026-11-24 [email protected] [flutter_tools] Pass featureFlags in localizations_test.dart (flutter/flutter#197269)
2026-11-23 [email protected] Fix Orca flat review in Linux accessibility (flutter/flutter#196338)
2026-11-23 [email protected] [flutter tools] Pass --client-id=flutter-analyze to the analysis server (flutter/flutter#197227)
2026-11-23 [email protected] [Flutter GPU] Expose the maximum render target size (flutter/flutter#196640)
2026-11-23 [email protected] iOS: Don't clear raster thread state in platform views reset (flutter/flutter#197025)
2026-11-23 [email protected] iOS: Composite platform views from layers in tests (flutter/flutter#197021)
2026-11-23 [email protected] [flutter_tools] Harden extension diagnostics models and RPC failure handling (flutter/flutter#196233)
2026-11-23 [email protected] [flutter_tools] Support standalone UI packages in gen-l10n (flutter/flutter#194500)
2026-11-23 [email protected] [flutter_tools] Consolidate ToolDependencies.bootstrap builders and require extension managers (flutter/flutter#196388)
2026-11-23 [email protected] Roll Skia from 31b19bdc8195 to 694af434cadd (2 revisions) (flutter/flutter#197239)
2026-11-23 [email protected] Roll Dart SDK from df632229552e to 10aef26c73f5 (1 revision) (flutter/flutter#197234)
2026-11-23 [email protected] [macOS] Fix back buffer cache returning a wrong-size surface (Impeller null deref in Canvas::SetupRenderPass) (flutter/flutter#192522)
2026-11-23 [email protected] Add Settings::frame_built_callback for UI frame build timings (flutter/flutter#197213)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD t: extensions Issues related to Flutter Tools extensions tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants