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

VSCode.dev can't switch branches in private repositories #138517

Closed
seanofw opened this issue Oct 22, 2021 · 7 comments
Closed

VSCode.dev can't switch branches in private repositories #138517

seanofw opened this issue Oct 22, 2021 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@seanofw
Copy link

seanofw commented Oct 22, 2021

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: VSCode.dev
  • OS Version: Windows 10, 64-bit

Steps to Reproduce:

  1. Open vscode.dev.
  2. Open a private repository on GitHub in vscode.dev.
  3. At the bottom, click where it says master (or whatever the default branch is named).
  4. In the popup that appears, click on any branch other than master.
  5. The page will flash white and reload, and the Explorer section will be blank.

This appears to only happen in my private repositories; it doesn't seem to happen in any of the public ones. It can correctly load master from the private repositories, just not other branches.

I'm using Firefox 93, 64-bit, on Windows 10 64-bit.

I just heard about VSCode.dev tonight and thought I'd give it a spin, so I opened it, pointed it at the repository I've been working in lately, switched to the branch I've been working in, and — immediately it broke :(

@lramos15
Copy link
Member

I can reproduce with repos that require SAML. I.e. some of the private Microsoft ones, but not with my personal private repos. @seanofw Do your private repos happen to be org repos that require single sign on?

@seanofw
Copy link
Author

seanofw commented Oct 22, 2021

My private repos are personal, private repos on GitHub. I do have 2FA enabled for my account, though, so it's quite possible that it's still doing corporate-like SSO-ish things with them.

@joyceerhl
Copy link
Collaborator

joyceerhl commented Oct 22, 2021

@seanofw do you have slashes in the names of the branches that you're trying to switch to? And if you install the GitHub Repositories extension on desktop VS Code, can you switch branches in the same repo?

@joyceerhl
Copy link
Collaborator

OK, it looks like this is a bug in how the workbench embedder parses branch names for private repos. Public repos are unaffected because no authentication is required to validate the branch name against the GitHub APIs.

@joyceerhl
Copy link
Collaborator

The problem is that for treeish GitHub urls, we can't tell where the branch name (which can contain slashes) ends and the directory path begins. For example,

So in the dev branch case above, our current code assumes that TylerLeonhardt is the branch name and fix-quickpick-focus/resources is the directory path. The default branch works because main is indeed the branch name.

This bug impacts vscode.dev only and not github.dev or desktop RemoteHub, because you have to sign into GitHub to access github.dev, and RemoteHub asks you to sign into GitHub when accessing a GitHub repo as well.

To handle opening treeish urls in private repos correctly, some component in the vscode.dev -> RemoteHub flow must be able to make an authenticated GH extract-ref API call (which is how github.dev deals with this problem) to validate the url.

  1. One thought is we could delegate all the url handling for private repos back to RemoteHub instead of trying to parse them in the workbench embedder, since there's no heuristic we can use to parse urls ourselves. This means private repos won't benefit from the editor defaultLayout work we've done, since we have to wait for the extension to activate first
  2. I believe there was also some discussion regarding creating a url resolver extension which can handle the url parsing. Again, we have to wait for the extension to activate to handle the url
  3. Would it make sense to require auth in the workbench embedder for private repos? The user already needs to authenticate in that case. cc @joaomoreno @TylerLeonhardt for additional thoughts

@seanofw
Copy link
Author

seanofw commented Oct 23, 2021

@joyceerhl Indeed I do use slash-delimited branch names, and I'll bet that's the exact cause. I use branch names like feature/foo and bugfix/bar and release/baz in almost every repository I work with: It's a pretty common pattern.

Admittedly, while invoking the extract-ref API is probably the right answer, you might want to consider implementing a cheat in the short term and allow for a user-specified wildcard pattern or a regex to be specified in the configuration somewhere that indicates either what part of the path is the branch name (feature/), or directly indicates how to decompose it (^(?<branch>\w*)\/(?<path>.*)$). That's hacktacular, but it's also a really trivial solution to implement, while invoking the API is probably a lot more complex. Just a thought.

@joaomoreno
Copy link
Member

Correct, this won't work unless we come up with a way for a lightweight extension host to spin up both the GitHub Authentication and RemoteHub extensions, let them auth and resolve the workspace and only then open it up. This is somewhat what already happens in remote. I've had discussions about it with @bpasero. Also cc @alexdima @aeschli.

@joyceerhl joyceerhl transferred this issue from microsoft/vscode Oct 25, 2021
@joyceerhl joyceerhl transferred this issue from microsoft/vscode-remote-repositories-github Dec 6, 2021
@joyceerhl joyceerhl added this to the November 2021 milestone Dec 6, 2021
@joyceerhl joyceerhl added bug Issue identified by VS Code Team member as probable bug verified Verification succeeded labels Dec 6, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants