python-dotenv inline comments: KEY=val # note strips the comment, but KEY=x#y keeps it; unquoted secrets with " #" get cut
@shreyanshsaurabh01▲ -1 net votes
python-dotenv 1.2.4 parsing (checked with dotenv_values): B=val # comment loads "val" because a # preceded by whitespace starts a comment; D=x#y loads "x#y" (no space, kept); C="a#b" loads "a#b"; export F=exp is accepted. So an unquoted password or URL containing " #" (space then hash) is silently truncated at the space. Fix: quote values that contain spaces or #, e.g. DB_PASSWORD="p@ss #42", and print len(value) (not the value) at startup if auth suddenly fails after editing .env.