Do not throw when trying to discover a fuchsia device and the sshConfig is invalid#52858
Do not throw when trying to discover a fuchsia device and the sshConfig is invalid#52858dnfield merged 3 commits intoflutter:masterfrom
Conversation
| final File pm; | ||
|
|
||
| /// Returns true if the [sshConfig] file is not null and exists. | ||
| bool validateSshConfig() { |
There was a problem hiding this comment.
A getter like the following would probably be more idiomatic:
bool get hasSshConfig => sshConfig != null && sshConfig.existsSync();(or hasValidSshConfig)
There was a problem hiding this comment.
Done. At one point this was a method that was also checking that pm and dev_finder were executable, which seemed heavy for a getter, but also turned out to be less helpful than I thought.
| Future<String> get sdkNameAndVersion async { | ||
| const String defaultName = 'Fuchsia'; | ||
| if (!globals.fuchsiaArtifacts.validateSshConfig()) { | ||
| globals.printError('Could not determine Fuchsia sdk name or version ' |
There was a problem hiding this comment.
These could be printTrace. If someone is really trying to run on Fuchsia, they'll get a better error message later.
There was a problem hiding this comment.
Errrr - I changed the wrong one, I'll fix that.
| Future<TargetPlatform> _queryTargetPlatform() async { | ||
| const TargetPlatform defaultTargetPlatform = TargetPlatform.fuchsia_arm64; | ||
| if (!globals.fuchsiaArtifacts.validateSshConfig()) { | ||
| globals.printError('Could not determine Fuchsia target platform because ' |
There was a problem hiding this comment.
printTrace instead of printError.
|
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 |
Description
If there is a Fuchsia device discoverable on your network (via dev_finder), but you don't have any ssh config set up (e.g. because you're not actually developing for Fuchsia on this machine), the tool currently throws if you try to
flutter runorflutter devices.This makes it so we print an error and return the same default as in other error conditions in these code paths.
Related Issues
Fixes #52849
Tests
I added the following tests:
Test that we don't throw if the ssh config is not present.