Skip to content

Environment variables with URLs are incorrectly encoded with escape sequences (e.g., ':' becomes '\x3a') #248468

Closed

Description

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.100.0
  • OS Version: Linux

Description

After updating to VS Code version 1.100.0, environment variables containing URLs are incorrectly encoded with escape sequences in the terminal environment. This causes issues with applications that parse these URLs, particularly in Django applications where CORS and CSRF settings require properly formatted URLs.

Steps to Reproduce

  1. Open VS Code version 1.100.0 on Linux
  2. Set environment variables containing URLs in your VS Code settings or launch.json, for example:
    {
      "env": {
        "FRONTEND_HOST": "http://localhost:5173",
        "BACKEND_HOST": "http://localhost:8000"
      }
    }
  3. Open a terminal in VS Code and run env | grep HOST
  4. Observe that the colon characters in the URLs are escaped as \x3a

Expected Behavior

Environment variables containing URLs should preserve the exact format that was specified, including colons and other special characters, without escaping them.

Actual Behavior

The colon characters (:) in URLs are being escaped as \x3a, causing issues with applications that require properly formatted URLs. For example, Django rejects these malformed URLs in CSRF_TRUSTED_ORIGINS and CORS_ALLOWED_ORIGINS settings.

Example output when running env | grep HOST:

FRONTEND_HOST=http\x3a//localhost\x3a5173
BACKEND_HOST=http\x3a//localhost\x3a8000

Environment

  • VS Code Version: 1.100.0
  • OS: Linux
  • Python Extensions Installed:
    • Python (ms-python.python)
    • Pylance (ms-python.vscode-pylance)
    • GitHub Copilot (github.copilot)

Workaround

Use a script to manually fix the environment variables before running the application:

import os
os.environ['FRONTEND_HOST'] = 'http://localhost:5173'
os.environ['BACKEND_HOST'] = 'http://localhost:8000'

Additional Information

This issue causes Django applications to fail with errors such as:

(4_0.E001) As of Django 4.0, the values in the CSRF_TRUSTED_ORIGINS setting must start with a scheme (usually http:// or https://) but found http\x3a//localhost\x3a5173.
(corsheaders.E013) Origin 'http\\x3a//localhost\\x3a5173' in CORS_ALLOWED_ORIGINS is missing scheme or netloc

Activity

  1. VivianKeith commented on May 9, 2025

    @VivianKeith

    I also found this bug. When I update VSCode to 1.100 version, the content of $PATH become: ...\x3a.vscode-server/cli/servers/Stable-19e0f9e681ecb8e5c09d8784acaa/server/bin/remote-cli\x3a\....
    It seems like VSCode wrongly deals with environment varialbles encoding the ':' into '\x3a'. This leads to failed auto-activation of my conda env, beacause the conda env's python interperter and some dependencies path are not actually included in the $PATH which should be parsed by ":".

  2. jmesterh commented on May 9, 2025

    @jmesterh

    Upgraded VSCode to 1.100. I set environment variables in the devcontainer with the.env file.
    All my environment variables with http:// are now http\\x3a//
    This update needs to be pulled ASAP.

  3. Opsi commented on May 9, 2025

    @Opsi

    Upgraded VSCode to 1.100. I set environment variables in the devcontainer with the.env file. All my environment variables with http:// are now http\\x3a// This update needs to be pulled ASAP.

    I encountered the exact same problem. My workaround is that I run source .env in the terminal before starting my application. I agree this needs to be pulled ASAP

  4. Ryusuke-Kawasaki commented on May 9, 2025

    @Ryusuke-Kawasaki

    I am experiencing the same issue. I am developing a program in a Node.js environment and using dotenv to load environment variables. In this case, the issue can be avoided by temporarily applying the following solution:

    const dotenv = require('dotenv');
    dotenv.config({ override: true });  // ★ Added

    If you are using python-dotenv in a Python environment, I believe the issue can similarly be avoided with the following:

    from dotenv import load_dotenv
    load_dotenv(override=True)
  5. ababak commented on May 9, 2025

    @ababak

    This happens on Windows with GitBash as well. The PATH variable gets corrupted, with all the "C:" paths turning into "C\x3a". Reinstalling the previous version helps fix this, but it causes issues with the new extensions.

  6. added
    regressionSomething that used to work is now broken
    bugIssue identified by VS Code Team member as probable bug
    on May 9, 2025
  7. 27 remaining items

  8. MstikS2 commented on May 12, 2025

    @MstikS2

    Same issue Windows 10

  9. anthonykim1 commented on May 12, 2025

    @anthonykim1
    Contributor

    Can people try the latest vscode insider version? (the one with green icon).
    It should be resolved.
    Thanks all for your time!

  10. andprov commented on May 12, 2025

    @andprov

    Can people try the latest vscode insider version? (the one with green icon). It should be resolved. Thanks all for your time!

    The insider version works correctly.

    Image

  11. amunger commented on May 13, 2025

    @amunger
    Collaborator

    closing for verification

  12. cosmofactory commented on May 14, 2025

    @cosmofactory

    Same issue here,
    Version: 1.100.1 (user setup)
    Commit: 91fa95b
    Date: 2025-05-09T15:43:50.040Z
    Electron: 34.5.1
    ElectronBuildId: 11369351
    Chromium: 132.0.6834.210
    Node.js: 20.19.0
    V8: 13.2.152.41-electron.0
    OS: Windows_NT x64 10.0.22631

  13. stuaxocabinetoffice commented on May 15, 2025

    @stuaxocabinetoffice

    Please VSCode, make sure anything you do to affect the terminal environment is incredibly well tested - especially if being "helpful" by setting environment variables, the absolutely must be correct.

    Just venting so skip over this:

    I wasted over half a day trying to fix a co-workers environment because of this.

    The combination of VSCode helpfully reading the .env file, after unhelpfully mangling the contents thereof meant:

    I did not expect the contents of the VSCode terminal to be any different to a terminal outside.
    Our system was complaining because it was misconfigured.
    It took a while tracking this down, and of course I couldn't find a .env file where this value was coming from.
    Eventually realised it was being set in the terminal, then realised it was not being set outside.
    Then found this bug.. I'm glad it's been fixed, but if my experience is similar to others this has probably wasted hundreds of ours of developers time across the globe.

  14. andprov commented on May 15, 2025

    @andprov

    Please VSCode, make sure anything you do to affect the terminal environment is incredibly well tested - especially if being "helpful" by setting environment variables, the absolutely must be correct.

    Just venting so skip over this:

    I wasted over half a day trying to fix a co-workers environment because of this.

    The combination of VSCode helpfully reading the .env file, after unhelpfully mangling the contents thereof meant:

    I did not expect the contents of the VSCode terminal to be any different to a terminal outside. Our system was complaining because it was misconfigured. It took a while tracking this down, and of course I couldn't find a .env file where this value was coming from. Eventually realised it was being set in the terminal, then realised it was not being set outside. Then found this bug.. I'm glad it's been fixed, but if my experience is similar to others this has probably wasted hundreds of ours of developers time across the globe.

    The problem is that we’ve grown accustomed to the convenience provided by the IDE. We’ve either forgotten or never learned the basic commands that need to be executed in the runtime environment when starting a project.

    VS Code takes care of things like defining paths, initializing variables, and more. However, in a production environment where there’s no VSCode or any other IDE, these tasks need to be done manually, using commands, scripts, Docker containers, etc.

    I agree that VSCode developers should test the behavior of core interaction tools like the terminal more thoroughly, but we must also keep in mind all the work the IDE is doing for us "under the hood."
    If you'd prefer, you can always disable this "magic."

  15. boilednut commented on May 15, 2025

    @boilednut

    The problem is that we’ve grown accustomed to the convenience provided by the IDE. We’ve either forgotten or never learned the basic commands that need to be executed in the runtime environment when starting a project.

    It may be "a problem" that exacerbates the effects of "the problem"; but, it's not "the problem". "The problem" is the VSCode developers releasing code with -- based on how egregious the bug is -- little to no regression testing.

  16. demiton commented on May 17, 2025

    @demiton

    Same problem after installing some python's extensions on vscode. I was getting bad urls https\x3a// after starting my nodeJs projects. By disabling all python's extension, I have got back correct urls.

  17. iamaakashbasnet commented on May 19, 2025

    @iamaakashbasnet

    Same problem here (using django-environ). Urls in env gets parsed to something like this: 'http\x3a//localhost\x3a8000'.
    It works fine in pycharm, but vscode causing the issue.

  18. locked and limited conversation to collaborators on Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugcandidateIssue identified as probable candidate for fixing in the next releaseregressionSomething that used to work is now brokenterminal-processProblems launching processes, managing ptys, exiting, process leaks, etc.verifiedVerification succeeded

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions