Repository navigation
[flutter_tools] Harden extension diagnostics models and RPC failure handling - #196233
Conversation
…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
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
There was a problem hiding this comment.
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.
|
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
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
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
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
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
Previously,
ValidationMessageomittedpiiStrippedMessagefrom equality and skippedpiiStrippedMessageandcontextUrlvalidation infromJson,ValidationResultexposed a mutableexecutionTimewithout value equality and defaulted missing or unknowntypevalues toValidationType.successinfromJson,ValidationResult.crashhardcodedhttps://github.com/flutter/flutter/issuesin partner-facingpackage:flutter_tools_core, andDiagnosticsExtensionClient.runDiagnosticsinherited the 5-second metadata RPC timeout while catching RPC and parse failures withprintTraceand returning an empty list (whichExtensionDoctorValidatorreported as[✓]).This change marks
ValidationMessageandValidationResultas immutablefinalclasses, includes all fields in==andhashCode, wrapsValidationResult.messagesinList.unmodifiable, preserves pre-populatedexecutionTimevalues inDoctorValidator.validate, enforces required fields and enum/type invariants infromJsonandValidationResult.listFromJson, removesValidationResult.crashin favor ofDoctorValidator.createCrashResultso built-in validators preservehttps://github.com/flutter/flutter/issueswhileExtensionDoctorValidatorattributes crashes andDoctor.doctorDurationtimeouts to the extension package, and updatesDiagnosticsExtensionClient.runDiagnosticsto passtimeout: null, trace the failure namingconnection.extensionName, and return an extension-attributed crash result on failure.Output from
Doctor.diagnose(verbose: false)with anExtensionDoctorValidatorwrapping aDiagnosticsExtension(my_test_extension) whoserunDiagnosticsthrows aStateError:Previous output:
Current output:
Part of #190755
Part of #190747
Pre-launch Checklist
///).