microsoft / vscode-pull-request-github

GitHub Pull Requests for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github
MIT License
2.32k stars 582 forks source link

GitHub PR eventually hangs due to `git+ssh://` scheme being in a remote #3675

Closed errietta closed 2 years ago

errietta commented 2 years ago

Update

We've learned some more info in this issue... please jump to https://github.com/microsoft/vscode-pull-request-github/issues/3675#issuecomment-1171360048


Original

Does this issue occur when all extensions are disabled? N/A because this is an extension bug

Steps to Reproduce:

We have an enterprise account but not a custom url (we just use normal github.com) The problem is that the extension sort of assumes you have a custom URL. You can see by the code here that it hits ${apiUri.scheme}://${apiUri.authority}/api/v3${path} However in normal api.github.com (which is what I used as my enterprise server url) there is no /api/v3/ so it does not work.

My proposal:

Happy to give more info if needed. Also, if there's some way to develop on this extension without having to compile whole vs code, I'd be happy to implement my proposal.

Thanks!

vscodenpa commented 2 years ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.68.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

errietta commented 2 years ago

Here's the output:

[Info  - 15:35:19.9] Logging in for the following scopes: read:user repo user:email workflow
[Info  - 15:35:21.69] Getting token scopes...
[Error  - 15:35:21.223] Getting scopes failed: Not Found
[Error  - 15:35:21.223] Not Found
[Error  - 15:35:21.224] Error: network error

And same thing is happening on 1.68.1

errietta commented 2 years ago

basically this:

curl --location --request GET 'https://api.github.com/api/v3/' \
--header 'Authorization: token <redacted>' 

Doesn't work

curl --location --request GET 'https://api.github.com/' \
--header 'Authorization: token <redacted>'

Works fine

errietta commented 2 years ago

I've caved in and built vscode locally, but I need some help as I'm not sure how to develop on builtin extensions

TylerLeonhardt commented 2 years ago

@errietta thanks for taking this on! One thing that came to mind... does the regular github auth provider work for your accounts? The regular auth provider uses the Public API endpoints so I'm just wondering if that one, which is far superior of an experience than the PAT flow, could work for you.

errietta commented 2 years ago

@TylerLeonhardt it's some weird mixed experience for me. Some stuff seems to work fine without and some others (especially anything to do with opening/commenting on pull requests from within Code) doesn't work without the PAT flow 🤔 We use GitHub public API but we do have an organisation (enterprise account) with SSO so I wonder if something is confusing things there.

errietta commented 2 years ago

@TylerLeonhardt it's possible that "normal extension" works fine for some time, but then the SSO identification expires and there is just no way to "reconnect it" in vs code - that's another possibility I'm thinking about? While with the PAT you have the SSO connection active until the PAT expires and then you can provide a new PAT.

TylerLeonhardt commented 2 years ago

When going through the login flow for the github provider, you should see something like this: image

Both Microsoft & GitHub orgs are SSO enabled so I feel like you and I should have very similar experiences and that you should be able to just use the "normal extension".

And SAML should stay active for that access token for its entire life... but I have some internal contacts that I can reach out to if you've seen otherwise.

Additionally, the GitHub extensions that we own (GH Pull Request, GH Issue Notebooks, GH Repositories) should all have fairly robust error handling to guide you through re-authing if your token doesn't have the right SAML permissions for the org/repo you're trying to access. Though, like all software, their may be a bug.

errietta commented 2 years ago

@TylerLeonhardt yeah, I do get that screen but I seem to at times end up in a state where it's no longer working right. It seems to be fine for me right now so I guess I can ping if it breaks again.

TylerLeonhardt commented 2 years ago

@errietta please do! I'd like to understand your issue more as I would much prefer you go through the OAuth flow instead of using a PAT. It's a lot smoother.

errietta commented 2 years ago

@TylerLeonhardt the error has resurfaced. I'm not seeing the "github enterprise authentication" plugin output though. Just github authentication.

image

I don't see any error or prompt to re-login but pull requests and issues stays empty.

TylerLeonhardt commented 2 years ago

@errietta is there a GitHub Pull Requests Output channel? Can you share with me what's in that?

Additionally any errors in the console of Dev Tools (which you can get to by searching Developer Tools in the Command Palette).

I want to see if maybe GitHub Pull Request extension is having trouble handling some error... like SAML fell off

errietta commented 2 years ago

@TylerLeonhardt saw this in the pull requests output

[Info] GitHubServer> No response from host https://git%2Bssh/COMPANY/REPO: request to https://git+ssh/api/v3/rate_limit failed, reason: getaddrinfo ENOTFOUND git+ssh
[Info] No remotes found. The following remotes are missing: origin, upstream
[Info] No GitHub remotes found
[Info] Review> no matching pull request metadata found for current branch integration
[Info] Review> no matching pull request metadata found on GitHub for current branch integration
[Info] PullRequestTree> Removing PR #undefined from tree

It looks like it sometimes (not always!) url encodes git+ssh://?

btw the git remote is obv fine

erry@Spare-22 ~/work/folder $ (integration) > git remote show origin                                 (integration)
* remote origin
  Fetch URL: git+ssh://git@github.com/company/repo
TylerLeonhardt commented 2 years ago

@errietta yeah that https://git%2Bssh looks very suspicious. I think this might be an issue with GHPR not handling your remote with git+ssh:// in it. Let's move this over to GHPR and start there.

btw, what does:

git remote -v

return?

if it contains the git+ssh:// I wonder what would happen if you got rid of that and instead had:

git@github.com/company/repo

which is what GitHub gives you:

git@github.com:microsoft/vscode.git

image

errietta commented 2 years ago

🤦 will try that,. however I'd say it should still be able to handle it. Seems to work with the new way for now at least! I think that will probably do it :) @TylerLeonhardt

alexr00 commented 2 years ago

Thanks for trying that out @errietta. Do you know how you ended up with the git+ssh scheme in your remote? It shouldn't be a problem for this extension to handle it, but I'm curious how this state happens.

errietta commented 2 years ago

@alexr00 I manually typed the remote, and that's the scheme I'm used to using off by heart. It's supported by git, so I didn't think it'd be an issue

alexr00 commented 2 years ago

@errietta makes sense! I will add support for it.

alexr00 commented 2 years ago

@errietta the fix will be available in the pre-release build of GitHub Pull Requests and Issues by Friday. It ended up being suspiciously simple, so if you have a chance to try it out after Friday it would help to confirm that the fix is good!

errietta commented 2 years ago

@errietta the fix will be available in the pre-release build of GitHub Pull Requests and Issues by Friday. It ended up being suspiciously simple, so if you have a chance to try it out after Friday it would help to confirm that the fix is good!

Sure please ping me when it's released and I'll try out

errietta commented 2 years ago

Hi @alexr00 tried this today with a git+ssh remote and looking good 👍

alexr00 commented 2 years ago

@errietta thank you for trying it out!

Josar commented 2 years ago

Hello All,

i tried to log into our GHE server with "vscode-pull-request-github" but always get an Network error, after i supply the PAT.

[2022-07-22 15:44:30.473] [exthost] [error] Error: network error
    at _ (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\github-authentication\dist\extension.js:1:708855)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async t.GitHubEnterpriseServer.login (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\github-authentication\dist\extension.js:1:717452)
    at async t.GitHubAuthenticationProvider.createSession (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\github-authentication\dist\extension.js:1:706656)

Any tips to resolve that? Or guidance on how to debug this? @errietta you seem to know how to debug VS code plugins maybe you can help me with that?

I allready switched the plugin to preview v0.47.2022072109 VS Code 1.69.2

alexr00 commented 2 years ago

@Josar please open a new issue with these details. This issue is just about having git+ss:// in your git remote.