Repository: flutter
Issue: FormatException: Invalid UTF-8 byte (at offset 59) when checking USB connection
Labels: waiting for customer response,in triage

### Steps to reproduce

Flutter crash report.
Please report a bug at https://github.com/flutter/flutter/issues.

## command

flutter daemon

## exception

FormatException: FormatException: Invalid UTF-8 byte (at offset 59)

```
#0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1950:7)
#1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:304:28)
#2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:300:5)
#3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:69:18)
#4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#5      _rootRunUnary (dart:async/zone.dart:1422:47)
#6      _CustomZone.runUnary (dart:async/zone.dart:1324:19)
#7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
#8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
#9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
#10     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:777:19)
#11     _StreamController._add (dart:async/stream_controller.dart:651:7)
#12     _StreamController.add (dart:async/stream_controller.dart:606:5)
#13     _Socket._onData (dart:io-patch/socket_patch.dart:2455:41)
#14     _rootRunUnary (dart:async/zone.dart:1430:13)
#15     _CustomZone.runUnary (dart:async/zone.dart:1324:19)
#16     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
#17     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
#18     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
#19     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:777:19)
#20     _StreamController._add (dart:async/stream_controller.dart:651:7)
#21     _StreamController.add (dart:async/stream_controller.dart:606:5)
#22     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1942:33)
#23     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1385:14)
#24     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#25     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#26     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#27     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
```

## flutter doctor

```
[!] Flutter (Channel stable, 3.27.2, on Debian GNU/Linux 12 (bookworm) 6.6.62+rpt-rpi-2712, locale en_GB.UTF-8)
    • Flutter version 3.27.2 on channel stable at /home/<Ja>/Tvorba/flutter
    ! The flutter binary is not on your path. Consider adding /home/<Ja>/Tvorba/flutter/bin to your path.
    ! The dart binary is not on your path. Consider adding /home/<Ja>/Tvorba/flutter/bin to your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68415ad1d9 (12 days ago), 2025-01-13 10:22:03 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
    • Android SDK at /usr/lib/android-sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.13+11-Debian-2deb12u1)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Debian clang version 14.0.6
    • cmake version 3.25.1
    • ninja version 1.11.1
    • pkg-config version 1.8.1

[✓] Android Studio (version 2024.2)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 83.0.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.13+11-Debian-2deb12u1)

[✓] VS Code (version 1.96.4)
    • VS Code at /usr/share/code
    • Flutter extension version 3.102.0

[☠] Connected device (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.
    ✗ FormatException: Invalid UTF-8 byte (at offset 59)
    • #0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1950:7)
      #1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:304:28)
      #2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:300:5)
      #3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:69:18)
      #4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
      #5      _rootRunUnary (dart:async/zone.dart:1422:47)
      #6      _CustomZone.runUnary (dart:async/zone.dart:1324:19)
      #7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
      #8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
      #9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
      #10     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:777:19)
      #11     _StreamController._add (dart:async/stream_controller.dart:651:7)
      #12     _StreamController.add (dart:async/stream_controller.dart:606:5)
      #13     _Socket._onData (dart:io-patch/socket_patch.dart:2455:41)
      #14     _rootRunUnary (dart:async/zone.dart:1430:13)
      #15     _CustomZone.runUnary (dart:async/zone.dart:1324:19)
      #16     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
      #17     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
      #18     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
      #19     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:777:19)
      #20     _StreamController._add (dart:async/stream_controller.dart:651:7)
      #21     _StreamController.add (dart:async/stream_controller.dart:606:5)
      #22     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1942:33)
      #23     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1385:14)
      #24     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
      #25     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
      #26     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
      #27     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
```

In visual studio flutter is hit and miss sometimes crashing when attempting to chose or add target with same output and sometime crashing on load (again with similar log).
I have multiple locales on this computer including SK, CS, RU, UA but all with utf-8


In regards to less important issue:
Contrary to flutter checks occasional claim, (most cases it does not claim its address missing in PATH, flutter is run and works from any location without specifying path to it and echo $PATH includes the correct path.

### Expected results

Flutter continues runnning enables chosing target at  without having to restart after adding new targets

### Actual results

 have to restart Visual studio code sometimes several times each time adding target Linux. even clicking on chice crashes the flutter with output above

### Code sample

Tutorials first code

### Screenshots or Video

_No response_

### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

flutter doctor -v
```
[✓] Flutter (Channel stable, 3.27.2, on Debian GNU/Linux 12 (bookworm)
    6.6.62+rpt-rpi-2712, locale en_GB.UTF-8)
    • Flutter version 3.27.2 on channel stable at /home/<Ja>/Tvorba/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68415ad1d9 (12 days ago), 2025-01-13 10:22:03 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version
    35.0.1)
    • Android SDK at /usr/lib/android-sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.13+11-Debian-2deb12u1)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = chromium

[✓] Linux toolchain - develop for Linux desktop
    • Debian clang version 14.0.6
    • cmake version 3.25.1
    • ninja version 1.11.1
    • pkg-config version 1.8.1

[✓] Android Studio (version 2024.2)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 83.0.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.13+11-Debian-2deb12u1)

[✓] VS Code (version 1.96.4)
    • VS Code at /usr/share/code
    • Flutter extension version 3.102.0

[☠] Connected device (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.
    ✗ FormatException: Invalid UTF-8 byte (at offset 59)
    • #0      _Utf8Decoder.convertChunked
      (dart:convert-patch/convert_patch.dart:1950:7)
      #1      _Utf8ConversionSink.addSlice
      (dart:convert/string_conversion.dart:304:28)
      #2      _Utf8ConversionSink.add
      (dart:convert/string_conversion.dart:300:5)
      #3      _ConverterStreamEventSink.add
      (dart:convert/chunked_conversion.dart:69:18)
      #4      _SinkTransformerStreamSubscription._handleData
      (dart:async/stream_transformers.dart:111:24)
      #5      _rootRunUnary (dart:async/zone.dart:1422:47)
      #6      _CustomZone.runUnary (dart:async/zone.dart:1324:19)
      #7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
      #8      _BufferingStreamSubscription._sendData
      (dart:async/stream_impl.dart:366:11)
      #9      _BufferingStreamSubscription._add
      (dart:async/stream_impl.dart:297:7)
      #10     _SyncStreamControllerDispatch._sendData
      (dart:async/stream_controller.dart:777:19)
      #11     _StreamController._add
      (dart:async/stream_controller.dart:651:7)
      #12     _StreamController.add
      (dart:async/stream_controller.dart:606:5)
      #13     _Socket._onData (dart:io-patch/socket_patch.dart:2455:41)
      #14     _rootRunUnary (dart:async/zone.dart:1430:13)
      #15     _CustomZone.runUnary (dart:async/zone.dart:1324:19)
      #16     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
      #17     _BufferingStreamSubscription._sendData
      (dart:async/stream_impl.dart:366:11)
      #18     _BufferingStreamSubscription._add
      (dart:async/stream_impl.dart:297:7)
      #19     _SyncStreamControllerDispatch._sendData
      (dart:async/stream_controller.dart:777:19)
      #20     _StreamController._add
      (dart:async/stream_controller.dart:651:7)
      #21     _StreamController.add
      (dart:async/stream_controller.dart:606:5)
      #22     new _RawSocket.<anonymous closure>
      (dart:io-patch/socket_patch.dart:1942:33)
      #23     _NativeSocket.issueReadEvent.issue
      (dart:io-patch/socket_patch.dart:1385:14)
      #24     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
      #25     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
      #26     _runPendingImmediateCallback
      (dart:isolate-patch/isolate_patch.dart:118:13)
      #27     _RawReceivePort._handleMessage
      (dart:isolate-patch/isolate_patch.dart:185:5)


[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```