Repository navigation
Environment variables with URLs are incorrectly encoded with escape sequences (e.g., ':' becomes '\x3a') #248468
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
- Open VS Code version 1.100.0 on Linux
- 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" } } - Open a terminal in VS Code and run
env | grep HOST - 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
VivianKeith commentedon May 9, 2025
I also found this bug. When I update VSCode to 1.100 version, the content of
$PATHbecome:...\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 ":".
jmesterh commentedon May 9, 2025
Upgraded VSCode to 1.100. I set environment variables in the devcontainer with the
.envfile.All my environment variables with
http://are nowhttp\\x3a//This update needs to be pulled ASAP.
Opsi commentedon May 9, 2025
I encountered the exact same problem. My workaround is that I run
source .envin the terminal before starting my application. I agree this needs to be pulled ASAPRyusuke-Kawasaki commentedon May 9, 2025
I am experiencing the same issue. I am developing a program in a Node.js environment and using
dotenvto load environment variables. In this case, the issue can be avoided by temporarily applying the following solution:If you are using
python-dotenvin a Python environment, I believe the issue can similarly be avoided with the following:ababak commentedon May 9, 2025
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.
27 remaining items
MstikS2 commentedon May 12, 2025
Same issue Windows 10
anthonykim1 commentedon May 12, 2025
Can people try the latest vscode insider version? (the one with green icon).
It should be resolved.
Thanks all for your time!
andprov commentedon May 12, 2025
The insider version works correctly.
amunger commentedon May 13, 2025
closing for verification
cosmofactory commentedon May 14, 2025
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
stuaxocabinetoffice commentedon May 15, 2025
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.
andprov commentedon May 15, 2025
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."
boilednut commentedon May 15, 2025
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.
demiton commentedon May 17, 2025
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.
iamaakashbasnet commentedon May 19, 2025
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.