Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: HTTPS_PROXY not work with copilot CLI #75

Open
Dennis3453 opened this issue May 8, 2024 · 4 comments
Open

[BUG]: HTTPS_PROXY not work with copilot CLI #75

Dennis3453 opened this issue May 8, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Dennis3453
Copy link

Dennis3453 commented May 8, 2024

What happened?

gh copilot explain & suggest not using HTTPS_PROXY.
Other gh commands are okay (auth, search, status, etc)

Edited: The issue happened inside WSL ubuntu terminal, copilot cli works on Windows CMD

Versions

What versions of the relevant software are you running?
gh-copilot version 1.0.2 (2024-04-26)
gh version 2.49.0 (2024-04-30)
https://github.com/cli/cli/releases/tag/v2.49.0

Relevant terminal output

$ gh copilot explain "sth"
✗ Error: failed to create thread: error sending request: error making request: Post "https://api.githubcopilot.com/github/chat/threads": Proxy Authorization Required
@Dennis3453 Dennis3453 added bug Something isn't working needs-triage needs to be reviewed labels May 8, 2024
@andyfeller
Copy link
Contributor

@Dennis3453 : thank you for opening this issue and apologies for the trouble! 🙇

Edited: The issue happened inside WSL ubuntu terminal, copilot cli works on Windows CMD

Few questions for you:

  1. What version on Windows and Ubuntu?

  2. Is WSL being used through Visual Studio Code or terminal?

  3. What happens when you set the following environment variables and use the extension?

    export HTTP_PROXY="127.0.0.1:3128"
    export HTTPS_PROXY="127.0.0.1:3129"
    export http_proxy="127.0.0.1:3130"
    export https_proxy="127.0.0.1:3131"

    When I do this through VS Code on a WSL vm, I can see that the conventional environment variables are picked up in the following order:

    1. HTTPS_PROXY
    2. HTTP_PROXY
    3. https_proxy
    4. http_proxy
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 22.04.2 LTS
    Release:        22.04
    Codename:       jammy
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export HTTP_PROXY="127.0.0.1:3128"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export HTTPS_PROXY="127.0.0.1:3129"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export http_proxy="127.0.0.1:3130"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ export https_proxy="127.0.0.1:3131"
    andyfeller@DESKTOP-A5BGD8P:/mnt/c/Users/andre/Documents/cli/cli$ GH_DEBUG=api gh copilot suggest -t shell how to setup a proxy server on Windows 11
    * Request at 2024-05-13 09:48:46.430815229 -0400 EDT m=+0.125775764
    * Request to https://api.githubcopilot.com/github/chat/threads
    > POST /github/chat/threads HTTP/1.1
    > Host: api.githubcopilot.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: Bearer ████████████████████
    > Content-Length: 2
    > Content-Type: application/json
    > Time-Zone: America/New_York
    > User-Agent: go-gh
    > X-Github-Api-Version: 2023-07-07
    
    {}
    
    * Request at 2024-05-13 09:48:46.430940644 -0400 EDT m=+0.125901186
    * Request to https://api.github.com/repos/github/gh-copilot/releases/latest
    > GET /repos/github/gh-copilot/releases/latest HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token ████████████████████
    > Content-Type: application/json; charset=utf-8
    > Time-Zone: America/New_York
    > User-Agent: go-gh
    
    * proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused
    * Request took 139.721µs
    * proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused
    * Request took 278.711µs
    
    ✗ Error: failed to create thread: error sending request: error making request: Post "https://api.githubcopilot.com/github/chat/threads": proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused

@andyfeller andyfeller removed the needs-triage needs to be reviewed label May 13, 2024
@andyfeller andyfeller self-assigned this May 13, 2024
@Dennis3453
Copy link
Author

  1. What version on Windows and Ubuntu?
    OS Name Microsoft Windows 11 Pro
    Version 10.0.22631 Build 22631
    Ubuntu 20.04.6 LTS (GNU/Linux 5.15.150.1-microsoft-standard-WSL2 x86_64)

  2. WSL use through terminal

  3. What happens when you set the following environment variables and use the extension?
    ✗ Error: failed to create thread: error sending request: error making request: Post "https://api.githubcopilot.com/github/chat/threads": proxyconnect tcp: dial tcp 127.0.0.1:3129: connect: connection refused

@Dennis3453
Copy link
Author

I can use gh copilot now by setting HTTPS_PROXY instead of https_proxy. Thanks.

@andyfeller
Copy link
Contributor

@Dennis3453: do you have any ideas beyond a small mention in the README about setting HTTPS_PROXY env var to avoid the impact for the next person?

This isn't the first time I've ran into issues with CLIs in general in environments that require use of a proxy. These variables aren't CLI specific, which is generally why every CLI tools doesn't document their use. That said, I'd like to figure out the right amount of info to help the next person.

Does this affect any other CLIs you work with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants