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

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

Conversation

filfreire
Copy link
Member

@filfreire filfreire commented Dec 2, 2024

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 force-pushed the fix/INS-4742-file-paths-dont-work-json-editor-windows branch from 3c92781 to b524f43 Compare December 6, 2024 09:34
@filfreire filfreire force-pushed the fix/INS-4742-file-paths-dont-work-json-editor-windows branch 2 times, most recently from d83133d to f74ce3c Compare December 13, 2024 12:07
@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
Copy link
Contributor

@gatzjames gatzjames left a comment

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 force-pushed the fix/INS-4742-file-paths-dont-work-json-editor-windows branch from b6a5ddc to e0e61a4 Compare December 16, 2024 10:13
@filfreire filfreire enabled auto-merge (squash) December 16, 2024 10:13
@filfreire filfreire merged commit 9af247b into Kong:develop Dec 16, 2024
8 checks passed
@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