[GH-ISSUE #4672] [bug]: Whitespace in environment vars break CodeSnippet generation #1735

Open
opened 2026-03-16 21:34:12 +03:00 by kerem · 1 comment
Owner

Originally created by @piscis on GitHub (Jan 13, 2025).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4672

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I noticed that the Code Snippets generation fails if an url contains references to an environment variable with unescaped whitespaces.

For Example

If I have the following url: https://echo.hoppscotch.io/?query=abc 123 and setup a Request eg. https://echo.hoppscotch.io/?query=<<unescapedWhitespace>> with a variable abc 123 then I get the following error while generating a CodeSnippet

Screenshot 2025-01-13 at 11 48 00
with a javascript client error:
Screenshot 2025-01-13 at 11 48 14

Steps to reproduce

  1. Create a GET request to https://echo.hoppscotch.io/?query=abc 123
  2. Create a environment variable containing the string abc 123 name it unescapedWhitespace
  3. Modify the url to use the environment variable for the query parameter eg. https://echo.hoppscotch.io/?query=<<unescapedWhitespace>>
  4. Run the request and make sure it response with http status 200
  5. Create a CodeSnippet
  6. Notice the error Something went wrong

Workaround:
To fix the error replace the white space in unescapedWhitespace with an encoded white space so the value reads abc%20123

Run CodeSnippet again it should display a code snippet:

Screenshot 2025-01-13 at 11 55 10

Environment

Production

Version

Self-hosted
Docker: hoppscotch/hoppscotch:2024.12.0
Ubuntu 24.04

Originally created by @piscis on GitHub (Jan 13, 2025). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4672 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior I noticed that the Code Snippets generation fails if an url contains references to an environment variable with unescaped whitespaces. **For Example** If I have the following url: `https://echo.hoppscotch.io/?query=abc 123` and setup a Request eg. `https://echo.hoppscotch.io/?query=<<unescapedWhitespace>>` with a variable `abc 123` then I get the following error while generating a CodeSnippet ![Screenshot 2025-01-13 at 11 48 00](https://github.com/user-attachments/assets/7397b9d6-4fe5-4925-a360-3852df7fc6ed) with a javascript client error: ![Screenshot 2025-01-13 at 11 48 14](https://github.com/user-attachments/assets/3368550b-8f93-4be5-b50c-6f861d6d2c7b) ### Steps to reproduce 1. Create a GET request to `https://echo.hoppscotch.io/?query=abc 123` 2. Create a environment variable containing the string `abc 123` name it `unescapedWhitespace` 3. Modify the url to use the environment variable for the query parameter eg. `https://echo.hoppscotch.io/?query=<<unescapedWhitespace>>` 4. Run the request and make sure it response with http status 200 5. Create a CodeSnippet 6. Notice the error `Something went wrong` **Workaround:** To fix the error replace the white space in `unescapedWhitespace` with an encoded white space so the value reads `abc%20123` Run CodeSnippet again it should display a code snippet: ![Screenshot 2025-01-13 at 11 55 10](https://github.com/user-attachments/assets/7d4a771e-fb10-4fc9-9eae-670470d39e02) ### Environment Production ### Version Self-hosted Docker: hoppscotch/hoppscotch:2024.12.0 Ubuntu 24.04
Author
Owner

@yousefmarey12 commented on GitHub (Jan 14, 2025):

hey, I'll work on this.

<!-- gh-comment-id:2591004969 --> @yousefmarey12 commented on GitHub (Jan 14, 2025): hey, I'll work on this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1735
No description provided.