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

Extensions written in C# fail when opening files from remote repo and a non-default branch #375

Closed
StephenWeatherford opened this issue Oct 3, 2023 · 5 comments
Assignees
Labels
wont-fix This will not be worked on

Comments

@StephenWeatherford
Copy link

I've now seen this in two of our extensions:

Azure/bicep#11467
microsoft/vscode-azurearmtools#1647

Hard to believe no one else has seen this.
To repro:
Follow steps here: Azure/bicep#11467 (comment)

My investigation results are here: Azure/bicep#11467 (comment)

The problem is that for non-default branches, the URI we get for the document looks like this:

vscode-vfs://github%2B7b2276223a312c22726566223a7b2274797065223a342c226964223a225374657068656e57656174686572666f72642d70617463682d31227d7d/StephenWeatherford/template-examples/bicep/templatespec/client.bicep

This appears to technically be a valid URI, but OmniSharp (language server framework) and C#'s own System.Uri do not seem to handle it.

Example: System.Uri failing (whether the "+" is encoded or not):
new System.Uri("vscode-vfs://github+7b2276223a312c22726566223a7b2274797065223a342c226964223a225374657068656e57656174686572666f72642d70617463682d31227d7d/StephenWeatherford/template-examples/bicep/templatespec/client.bicep", System.UriKind.Absolute)
'new System.Uri("vscode-vfs://github+7b2276223a312c22726566223a7b2274797065223a342c226964223a225374657068656e57656174686572666f72642d70617463682d31227d7d/StephenWeatherford/template-examples/bicep/templatespec/client.bicep", System.UriKind.Absolute)' threw an exception of type 'System.UriFormatException'

System.Uri.IsWellFormedUriString() returns false.

By contrast, on the default branch the URI has this format:
github://github/StephenWeatherford/template-examples/bicep/main.bicep

@StephenWeatherford
Copy link
Author

Can you please provide guidance? We need to be able to parse the URIs for documents. Thanks.

@joyceerhl
Copy link
Contributor

Thanks for investigating. These are valid VS Code URIs based on our current validation logic which aims to match http://tools.ietf.org/html/rfc3986. The authority encodes information about the branch, so if you stripped out that data you would end up reading the contents of the main branch. We also use + in vscode-remote URI authorities. It's very unlikely that we'd be able to change this URI structure in Remote Repositories since it could cause data loss for uncommitted changes that are stored per-URI. IMHO as you've suggested dotnet/runtime#64707 is the upstream issue.

@StephenWeatherford
Copy link
Author

Understood, but that still leaves us and who knows how many other language servers vulnerable if we can't parse your URIs? Do you want us to disable our extension being loaded when it's not loaded locally? It looks like that might be what C# did, but feels like it kind of defeats the purpose of your extension?

@joyceerhl
Copy link
Contributor

While your extension is unable to handle these URIs with the .NET runtime's curent URI parsing implementation, it might be preferable to temporarily declare that your extension can't support virtual workspaces. You can do this in the package.json manifest with "virtualWorkspaces": false. Also cc @alexdima in case there is additional guidance on URIs that we can share.

@StephenWeatherford
Copy link
Author

We have disabled virtual workspaces.

@joyceerhl joyceerhl self-assigned this Dec 6, 2023
@joyceerhl joyceerhl added the wont-fix This will not be worked on label Dec 6, 2023
@joyceerhl joyceerhl closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wont-fix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants