-
Notifications
You must be signed in to change notification settings - Fork 769
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
Request textDocument/documentHighlight failed error in vscode when displaying Bicep files from Remote Repositories extension and from a non-default branch #11467
Comments
2023-08-07T21:45:30.142Z info: Current log level: debug. |
Version: 1.81.0 (user setup) |
@Aymope thanks for sharing. Is there any additional logging in the VSCode output window if you enable this VSCode setting? Is there anything otherwise unusual about your Windows install? (security policies, firewall config etc) |
I just made the server update to verbose. The error still pops up, maybe its a security policy or firewall config, let me check and update the issue. |
So the extension works now but the problem is that the extension works only on the default branch in the repo of the application. Anytime i create a new branch or use a different branch from the default branch the bicep extension doesn't work. Any idea why this problem? |
@Aymope Sorry you're having troubles with bicep. Having trouble thinking of why a different branch might be an issue. Could you try a few things and let us know how each turns out? Thanks!
Then restart vscode and reinstall the Bicep extension. Does that fix it? Thanks! |
@Aymope are you able to try out the steps that @StephenWeatherford shared? |
Yes, I tried those. But the issue was that the pipeline deployment process was set in a way that only the default branch can make code changes direct to ADO,I just got to find that out today. So another issue is when i changed the variables in the code so another branch can be able to make deployments, the variable change couldn't override the set up so another branch can make deployments and then, I wonder what all this has got to do with making the bicep extension fail on the other branches. |
@Aymope Sorry for the delay. I'm confused about your previous response. I asked you to run some steps on your local machine where I assume the problem is, to try and narrow it down, make sure it's not caused by another extension, and make sure the extension hasn't been corrupted. You've been able to verify all the above? You didn't answer any of the questions. I'm not sure what the rest of your response has to do with this, either. Thx. Also:
You didn't answer Marcin's question... He was hoping there might be something in the additional output before the error occurred that could give us a clue. Anything there look suspicious? Maybe you can share it if it's not sensitive? Thanks. Trying to figure out how to narrow this down. |
@StephenWeatherford I did run the steps and let me answer properly now. Disable all extensions except Bicep and .NET Install Tool for Extension Authors. Easiest way is to run "Disable all installed extensions" in the command palette, then re-enable Bicep. Does the issue still occur? Ans: Yes, the issue still occur Create and save an empty .bicep file (try both within your app repo and also outside of it). Restart vscode and open the file. Can you view/edit the file without issues? Ans: Yes the issue still exist in my app repo I carried out step 3 and 4 and the issue still occurred. To answer Marcin's question, there isn't any security policy or firewall config that makes this issue occur. To discuss how the repo is set up, I cloned the repo directly from ADO into VScode, For ease, I am able to access the repo using Azure repo extension. So to narrow this down, currently, the bicep extension works perfectly for only the default branch for the application and some months before now, all other branches were working. So now I am having this issue even after trying the 4 steps you had me go through. |
@Aymope - we are having trouble reproducing the issue. Would you be up for joining a call with us to watch the error occur live? That will help us do more troubleshooting in real time. |
That would be great, how do get the call rolling? |
My company uses Webex for calls, can we use this? |
Sure that's fine - can you send an email to [email protected] and we can set it up? |
@alex-frankel I sent you an email, did you receive it? |
Received - we will coordinate offline and update this thread if we have any meaningful updates on the issue. |
REPRO STEPS
![]()
![]()
![]()
![]() |
Recommendation: Disable use of Bicep language server in Remote Repositories extension as suggested here. Repro steps: #11467 (comment) Summary: The vscode Remote Repositories extension produces some weird but technically valid URIs for documents when displaying files in a different branch than the default branch. They're valid URIs but have a unusual (invalid?) hostname and dotnet's System.Uri throws an error if you try to create a Uri with that format (try here and here). Given that URIs are passed to extension via a string (or if using OmniSharp via a DocumentUri), and the first thing they generally do is to create and store a Uri from the string/DocumentUri, that means that the extension immediately fails in the handler. This affects our extension and probably many others. The dotnet bug relating to this is dotnet/runtime#64707. An opt-in argument to allow such URIs has been suggested as a possible fix here. Even if the dotnet bug is fixed, I'm not sure if it solves all the problems (see #12041), but in my opinion is a good first step for dotnet. It appears though that the Remote Repositories isn't the only extension producing such URIs, see gitkraken/vscode-gitlens#2978. microsoft/vscode#163225 talks about using "." instead of "+" in the domain name as a possible fix from the source of the URIs. Don't know what came of that, though. The bug I entered against Remote Repositories extension: microsoft/vscode-remote-repositories-github#375 |
NOTE: C# also disables virtual workspaces (https://github.com/dotnet/vscode-csharp/blob/e336406b01c0824af748931c8e0ca5434d0363a2/package.json#L34C32-L34C32). But they still seem to get intellisense, I think vscode must have that built in because I see that even if I uninstall the C# extensions. For Bicep, with this fix, looks exactly like it does for restricted mode: |
…ge] (#12259) Fixes #11467 See #11467 for more info. Sent that bug back to triage for approval. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/12259)
This is the first PR in a series of changes to introduce a file I/O abstraction layer to the Bicep project. Currently, `Bicep.Core` heavily relies on the large `IFileSystem` interface, `System.Uri`. This tight coupling introduces several challenges, such as making it difficult for the Bicep resource provider to supply a mock implementation of `IFileSystem`. Additionally, it prevents support for VS Code virtual workspaces because `System.Uri` is surprisingly not fully RFC-compliant (see: #11467). To address these issues, a higher-level abstraction for file I/O is required. Given the broad scope of this refactoring, this PR focuses on laying the groundwork by introducing the new abstraction layer and using it to load configuration. Subsequent PRs will replace the usage of `IFileSystem` and `System.Uri` throughout Bicep.Core and tidy up the `IFileResolver` interface with the new APIs. ## Key Changes in this PR The core of this PR is the introduction of a new `Bicep.IO` project. This project defines the new file I/O abstraction layer and includes: - `Bicep.IO.Abstraction` types: - `IFileExplorer`: Encapsulates directory and file discovery. - `IFileHandle`: A pointer to a file, abstracting operations like reading or writing. - `IDirectoryHandle`: A pointer to a directory for managing directory traversal. - `ResourceIdentifier`: An RFC3986 compliant URI (without Query and Fragment) which is going to replace `System.Uri` in `Bicep.Core`. - `Bicep.IO.FileSystem` types: - Concrete implementations of the above interfaces based on `IFileSystem`. The ultimate objective is to phase out direct usage of `Bicep.IO.FileSystem` within `Bicep.Core` and restrict it to referencing only `Bicep.IO.Abstraction` via `BannedSymbols.txt`. This design ensures cleaner separation of concerns and enables better testing, security, and support for virtual environments. Below is an architecture diagram illustrating the new design and how the layers interact: <img width="1446" alt="Untitled" src="https://github.com/user-attachments/assets/a68a8c73-31ca-4b54-bb2e-d4dc221108bf"> ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15568)
edit: see repro steps below: #11467 (comment)
Bicep version
Latest version
VScode: Latest version
I have been getting this error below on vscode, I cant do anything with the bicep code and i dont know why this problem cant go away
[Error - 12:12:13 PM] Request textDocument/documentHighlight failed.
Message: Internal Error
Code: -32603
[Error - 12:12:13 PM] Request textDocument/codeAction failed.
Message: Internal Error
Code: -32603
[Error - 12:12:14 PM] Request textDocument/hover failed.
Message: Internal Error
Code: -32603
The text was updated successfully, but these errors were encountered: