79619120

Date: 2025-05-13 07:13:32
Score: 3
Natty:
Report link

Perhaps the version of dotenv you're using might be having some issue (just a guess since I can't reproduce the same error). Maybe try changing (downgrading) the dotenv version you're using. Also, are you getting this issue just in your project directory or is it throughout your system? And are you getting the same problem both in VS Code terminal and OS terminal?

Or just sanitize every value in your env file (might potentially create a performance overhead) -

endpoint = os.getenv("ENDPOINT", "").encode("utf-8").decode("unicode_escape")
print(endpoint)

Or just parse the hex values using regex, something like this -

def decode_hex_escapes(s: str) -> str:
    return re.sub(
        r'\\x([0-9A-Fa-f]{2})',
        lambda m: chr(int(m.group(1), 16)),
        s
    )

endpoint = decode_hex_escapes(unquote(os.getenv("ENDPOINT", "")))
print(endpoint)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): getting the same problem
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Archit Mishra