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

Error in File Reference in file path containing %20 #9466

Closed
Andrew-D-Wilson opened this issue Jan 6, 2023 · 9 comments · Fixed by #11574
Closed

Error in File Reference in file path containing %20 #9466

Andrew-D-Wilson opened this issue Jan 6, 2023 · 9 comments · Fixed by #11574
Assignees
Labels
bug Something isn't working Needs: Upvote This issue requires more votes to be considered
Milestone

Comments

@Andrew-D-Wilson
Copy link

Bicep version
v0.13.1

Describe the bug
When working in a Git repository that's name contains spaces, the bicep 'module' then errors.

Such that if the cloned folder is demo%20repo, the error is as follows:
An error occurred reading file. Could not find a part of the path 'c:\src\demo repo\Bicep-Templates\storage-account.bicep'.

This also prevents building into ARM.

To Reproduce
Steps to reproduce the behavior:

  1. Create a folder with %20 in the name.
  2. Create a Bicep template with a module reference to another template.
  3. Error warning appears and inability to build.
@ghost ghost added the Needs: Triage 🔍 label Jan 6, 2023
@chielboogaard
Copy link

I got the same issue, if there is any solution hope it lands here

@anthony-c-martin
Copy link
Member

Possibly related to #8383

@anthony-c-martin
Copy link
Member

@Andrew-D-Wilson when you are building Bicep, are you using the VSCode "Build ARM Template" command, or are you using Azure CLI or Bicep CLI?

@Andrew-D-Wilson
Copy link
Author

@anthony-c-martin ,
I can build the ARM templates with Bicep CLI
I can Build the ARM templates with Azure CLI

I cant build with VSCode "Build ARM Templates"
The file is also indicated as having errors when opened in VSCode:
image

@anthony-c-martin
Copy link
Member

anthony-c-martin commented Jan 12, 2023

To me this looks like a bug in OmniSharp's DocumentUri.ToUri(), which we use to convert from the LSP URI to a .NET URI:

image

If we have a file path containing %20, the URI is correctly presented to the language server by VSCode containing escaped %2520. This appears to be correctly represented in documentUri (see screenshot). When we call documentUri.ToUri(), this appears to remove the escaping and instead represents the Uri with %20 - meaning this is considered to be a space instead of a legitimate %20 when the path is converted into a file system path using uri.LocalPath.

@anthony-c-martin
Copy link
Member

I added a test to repro this issue:

public async Task Module_resolution_does_not_work_for_file_paths_containing_escaped_spaces()

@stephaniezyen stephaniezyen added Needs: Upvote This issue requires more votes to be considered bug Something isn't working and removed Needs: Triage 🔍 labels Feb 1, 2023
@anthony-c-martin anthony-c-martin changed the title Error in File Reference in a Git Repository Containing Spaces Error in File Reference in file path containing %20 Feb 1, 2023
@riosengineer
Copy link

Is there any ETA on when this may be fixed please?

@segraef
Copy link

segraef commented Jul 24, 2023

same issue here by the way, once the repo name or the local folder contains a %20 Bicep is not able to reference the child module, just tested on Mac and Linux

in folder with %20

image

in folder without %20

image
image

@shenglol
Copy link
Contributor

shenglol commented Aug 18, 2023

I did some investigation, and this does seem to be an upstream bug in the Omnisharp LSP package: OmniSharp/csharp-language-server-protocol#1005. I'll be submitting a temp fix to the Bicep repo soon before the upstream bug is acknowledged and fixed.

@shenglol shenglol self-assigned this Aug 18, 2023
@shenglol shenglol moved this from Todo to In Progress in Bicep Aug 18, 2023
@shenglol shenglol modified the milestones: Committed Backlog, v0.21 Aug 18, 2023
@azcloudfarmer azcloudfarmer moved this from In Progress to In Review in Bicep Aug 22, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in Bicep Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Needs: Upvote This issue requires more votes to be considered
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants