Skip to content

Fix: File path fails when used in env vars on Windows [INS-4742]#8221

Merged
filfreire merged 3 commits into
Kong:developfrom
filfreire:fix/INS-4742-file-paths-dont-work-json-editor-windows
Dec 16, 2024
Merged

Fix: File path fails when used in env vars on Windows [INS-4742]#8221
filfreire merged 3 commits into
Kong:developfrom
filfreire:fix/INS-4742-file-paths-dont-work-json-editor-windows

Conversation

@filfreire

@filfreire filfreire commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

Fix

When we do a double-escape of the \ slash on tag-editor.tsx it solves the issue.

It seems before we were sanitizing the tag in different ways, and that didn't work, but it's unclear how it may have worked years ago. For now this change seems to do the trick

Explored some alternatives, but going down the path of JSON.stringify'ing the argument elsewhere, or trying to sanitize it elsewhere, becomes a trap quickly and doesn't fully work.

Investigation details here

Note: dragons 🐉 and spaghetti 🍝 ,

this is failing as far back as 2023. Tried with 10.1.1, 8.5.1 and even 2023.5.8. Found a bug report about it here: #5754

this is a sandworm/Shai-hulud type of issue for spending time

When using File template tags as value for environment variables in the JSON / non-table view of the Environment Editor, the file path gets stored with a bad path on the environment.

  • Does not seem to happen when setting the file template tag in the new environment table view editor, it's specific to the JSON view
  • Throughout the codebase there's a handful of places where we replace \\\\ to \\
  • There's also places where we do the oposite
  • By the time we get the values from Env Editor, it's showing up as \\ - which then magically dissappears when attempting to use the Env variable in a request, so a string like C:\\Users\\filipe\\Desktop\\test.txt ends up as C:\UsersfilipeDesktoptest.txt
  • In other cases it ends up weirder, particularly when using the Packaged app instead of the local development, where it ends up adding the AppData\Local\insomnia\app-10.2.0 path to the full bad path.
    image

image

image

Closes INS-4742

Closes #5754

@filfreire filfreire marked this pull request as draft December 2, 2024 15:11
@filfreire filfreire marked this pull request as ready for review December 13, 2024 12:08
@filfreire filfreire requested a review from a team December 13, 2024 12:26

@gatzjames gatzjames left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Windows and macOS LGTM

@filfreire filfreire enabled auto-merge (squash) December 16, 2024 10:13
@filfreire filfreire merged commit 9af247b into Kong:develop Dec 16, 2024
@filfreire filfreire deleted the fix/INS-4742-file-paths-dont-work-json-editor-windows branch December 16, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reading file in an environment variable does not translate into the query

2 participants