Bug Flutter proxy errors with username with _ special characters

This issue has been tracked since 2022-09-23.

Steps to Reproduce

  1. Behind corporate proxy
  2. Set user in proxy vars with _ in the user name e.g. http://user_with_underscore:[email protected]:8000
  3. run flutter pub get
  4. Cannot get

Logs

Logs
IO  : Get versions from https://pub.dartlang.org/api/packages/async.
IO  : HTTP GET https://pub.dartlang.org/api/packages/async
    | Accept: application/vnd.pub.v2+json
    | X-Pub-OS: linux
    | X-Pub-Command: get
    | X-Pub-Session-ID: 1696819A-D987-42E7-BB50-52B99ED7CB2C
    | X-Pub-Environment: flutter_bot:flutter_cli:verify:web
    | user-agent: Dart pub 2.17.1
IO  : Get versions from https://pub.dartlang.org/api/packages/collection.
IO  : Get versions from https://pub.dartlang.org/api/packages/meta.
SLVR: Version solving took 0:00:00.231739 seconds.
    | Tried 1 solutions.
FINE: Resolving dependencies finished (0.3s).
IO  : HTTP GET https://pub.dartlang.org/api/packages/collection
    | Accept: application/vnd.pub.v2+json
    | X-Pub-OS: linux
    | X-Pub-Command: get
    | X-Pub-Session-ID: 1696819A-D987-42E7-BB50-52B99ED7CB2C
    | X-Pub-Environment: flutter_bot:flutter_cli:verify:web
    | user-agent: Dart pub 2.17.1
IO  : HTTP GET https://pub.dartlang.org/api/packages/meta
    | Accept: application/vnd.pub.v2+json
    | X-Pub-OS: linux
    | X-Pub-Command: get
    | X-Pub-Session-ID: 1696819A-D987-42E7-BB50-52B99ED7CB2C
    | X-Pub-Environment: flutter_bot:flutter_cli:verify:web
    | user-agent: Dart pub 2.17.1
ERR : Invalid proxy configuration PROXY <proxy-info>

See the logs above: user has an _ in the username. When I use a user without _ it works. I tried hexadecimal chars and _ cannot be urlencoded. Curl to the url with the exact same http_proxy and https_proxy settings works.
darshankawar wrote this answer on 2022-09-23

Thanks for the report @iburrows
Please check this document and see if it helps https://dart.dev/tools/pub/troubleshoot#pub-get-fails-from-behind-a-corporate-firewall

See if using HTTP(S)_PROXY works, and if you are using quotation marks for passing environmental variable, ie, https_proxy, then try without quotation mark and see if it works.

And refer this https://stackoverflow.com/a/59510605 and check if that helps too.

iburrows wrote this answer on 2022-09-23

Thanks. I tried those and I set HTTP(S)_PROXY as well with and without quotes.
Unfortunately it still does not work.
I tried it with a user which does not have _ and it works fine. I was exporting the users in the exact same way. The only difference was the user with an _.

darshankawar wrote this answer on 2022-09-23

Thanks for the feedback. Keeping this issue open and labeling for team's insights.

/cc @jonahwilliams

christopherfujino wrote this answer on 2022-09-23

@iburrows I haven't set this before, can you give me a little more information about how to reproduce. Are you saying that you set the env variable https_proxy to a value with an underscore? And can you also share the output of flutter doctor -v?

iburrows wrote this answer on 2022-09-23

Hi @christopherfujino sure. Yes I export the http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY variables in a bashrc file. Specifically the user has an underscore in the name. As an example it would be export http_proxy=http://user_with_underscore:[email protected]:8000 and setting the rest of the env vars the same. In my case setting my own user which contains no _ flutter pub get works but with the user with _ it does not. I can curl the pub urls with the same user with _ set and it can get through the proxy so it is leading me to believe there is something that flutter/dart is doing.

flutter doctor -v

output
[✓] Flutter (Channel stable, 3.0.1, on Ubuntu 20.04.5 LTS 5.10.102.1-microsoft-standard-WSL2, locale C.UTF-8)
    • Flutter version 3.0.1 at /xxx/xxx/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fb57da5f94 (4 months ago), 2022-05-19 15:50:29 -0700
    • Engine revision caaafc5604
    • Dart version 2.17.1
    • DevTools version 2.12.2

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[☠] Linux toolchain - develop for Linux desktop (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.
    ✗ ProcessException: Failed to find "pkg-config" in the search path.
        Command: pkg-config 
    • #0      LocalProcessManager.run (package:process/src/interface/local_process_manager.dart:87:7)
      dart-lang/pub#1      ErrorHandlingProcessManager.run.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:669:24)
      dart-lang/pub#2      _run (package:flutter_tools/src/base/error_handling_io.dart:567:20)
      dart-lang/pub#3      ErrorHandlingProcessManager.run (package:flutter_tools/src/base/error_handling_io.dart:668:12)
      dart-lang/pub#4      LinuxDoctorValidator._libraryIsPresent (package:flutter_tools/src/linux/linux_doctor.dart:186:38)
      dart-lang/pub#5      LinuxDoctorValidator.validate (package:flutter_tools/src/linux/linux_doctor.dart:145:20)
      <asynchronous suspension>
      dart-lang/pub#6      Future.any.onValue (dart:async/future.dart:611:5)
      <asynchronous suspension>

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] Proxy Configuration
    • HTTP_PROXY is set
    • NO_PROXY is <no_proxy>
    • NO_PROXY contains localhost
    • NO_PROXY contains 127.0.0.1
    • NO_PROXY contains ::1

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.5 LTS 5.10.102.1-microsoft-standard-WSL2

[!] HTTP Host Availability
    ✗ HTTP host "https://cocoapods.org/" is not reachable. Reason: An error occurred while checking the HTTP host: Invalid proxy configuration PROXY
      user_with_underscore:[email protected]:8000
    ✗ HTTP host "https://maven.google.com/" is not reachable. Reason: An error occurred while checking the HTTP host: Invalid proxy configuration PROXY
      user_with_underscore:[email protected]:8000
    ✗ HTTP host "https://pub.dev/" is not reachable. Reason: An error occurred while checking the HTTP host: Invalid proxy configuration PROXY
      user_with_underscore:[email protected]:8000
    ✗ HTTP host "https://cloud.google.com/" is not reachable. Reason: An error occurred while checking the HTTP host: Invalid proxy configuration PROXY
      user_with_underscore:[email protected]:8000

! Doctor found issues in 5 categories.
christopherfujino wrote this answer on 2022-09-23

Hi @christopherfujino sure. Yes I export the http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY variables in a bashrc file. Specifically the user has an underscore in the name. As an example it would be export http_proxy=http://user_with_underscore:[email protected]:8000 and setting the rest of the env vars the same. In my case setting my own user which contains no _ flutter pub get works but with the user with _ it does not. I can curl the pub urls with the same user with _ set and it can get through the proxy so it is leading me to believe there is something that flutter/dart is doing.

flutter doctor -v

output

Thanks, this is perfect!

christopherfujino wrote this answer on 2022-09-26

This doesn't look to be a bug in the Flutter SDK, although I'm not sure if it's in the Dart SDK or in pub. I opened dart-lang/sdk#50084 for futher investigation.

iburrows wrote this answer on 2022-09-27
More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-10-04
Star Count 145499
Watcher Count 3567
Fork Count 23393
Issue Count 11206

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date