Skip to content

Flutter driver should provide better error handling for malformed RPCs #172127

Closed

Description

@jakemac53

Use case

Today if you call a flutter driver extension, they assume the RPCs are well formed. Presumably, this is safe today because the expectation is all these calls are coming from actual flutter driver API calls.

I am trying to integrate the Dart MCP server with flutter driver (see dart-lang/ai#222), and inevitably the LLMs will create bad RPC calls into flutter driver.

It would be very helpful if the error messages were better so the LLM could figure out its mistake. Mostly commonly what I see today is just raw null assertion errors or "too many elements" errors.

Proposal

All flutter_driver RPC handlers should have explicit error handling instead of using ! and .single, so that it can provide nice errors about which arguments were malformed, missing, etc.

Activity

  1. jakemac53 commented on Jul 14, 2025

    @jakemac53
    ContributorAuthor

    Some example output today:

    "Uncaught extension error while executing get_text: Bad state: Too many elements\\n#0      Iterable.single (dart:core/iterable.dart:696:24)\\n#1      CommandHandlerFactory._getText (package:flutter_driver/src/common/handler_factory.dart:436:45)\\n<asynchronous suspension>\\n#2      FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:423:31)\\n<asynchronous suspension>\\n#3      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:960:18)\\n<asynchronous suspension>\\n#4      _runExtension.<anonymous closure> (dart:developer-patch/developer.dart:138:13)\\n<asynchronous suspension>\\n\",\"type\":\"_extensionType\",\"method\":\"ext.flutter.driver\"
    

    and

    "Uncaught extension error while executing get_diagnostics_tree: Null check operator used on a null value\\n#0      new GetDiagnosticsTree.deserialize (package:flutter_driver/src/common/diagnostics_tree.dart:44:89)\\n#1      DeserializeCommandFactory.deserializeCommand (package:flutter_driver/src/common/deserialization_factory.dart:67:52)\\n#2      FlutterDriverExtension.deserializeCommand (package:flutter_driver/src/extension/extension.dart:470:18)\\n#3      FlutterDriverExtension.call (package:flutter_driver/src/extension/extension.dart:414:31)\\n#4      BindingBase.registerServiceExtension.<anonymous closure> (package:flutter/src/foundation/binding.dart:960:32)\\n<asynchronous suspension>\\n#5      _runExtension.<anonymous closure> (dart:developer-patch/developer.dart:138:13)\\n<asynchronous suspension>\\n\",\"type\":\"_extensionType\",\"method\":\"ext.flutter.driver\"
    
  2. added
    in triagePresently being triaged by the triage team
    toolAffects the "flutter" command-line tool. See also t: labels.
    t: flutter driver"flutter driver", flutter_drive, or a driver test
    c: proposalA detailed proposal for a change to Flutter
    a: error messageError messages from the Flutter framework
    team-toolOwned by Flutter Tool team
    and removed
    in triagePresently being triaged by the triage team
    on Jul 15, 2025
  3. tirth-patel-nc commented on Jul 15, 2025

    @tirth-patel-nc
    Member

    thanks for the report. labelled as a new proposal for team's tracking.

  4. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    P3Issues that are less important to the Flutter project
    and removed
    P2Important issues not at the top of the work list
    on Jul 29, 2025
  5. bkonyi commented on Jul 29, 2025

    @bkonyi
    Contributor

    This is definitely valid @jakemac53, but it's unlikely we're going to have cycles to prioritize this on the tool side (I'm not even completely sure who owns package:flutter_driver these days).

  6. jakemac53 commented on Jul 29, 2025

    @jakemac53
    ContributorAuthor

    I might be willing to take it on - it should be pretty trivial and would greatly improve the LLM experience. I run into this constantly

  7. self-assigned this
    on Jul 29, 2025
  8. github-actions commented on Sep 11, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projecta: error messageError messages from the Flutter frameworkc: proposalA detailed proposal for a change to Flutterr: fixedIssue is closed as already fixed in a newer versiont: flutter driver"flutter driver", flutter_drive, or a driver testteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions