Fix .env override priority and password whitespace stripping

Change load_dotenv() to load_dotenv(override=False) so real environment
variables always take priority over stale .env files. This prevents a
hardcoded or outdated REDMINE_API_KEY in .env from silently overriding
a fresh token exported in the shell (#15).

Add .strip() to get_redmine_password() for consistency with all other
config getters — trailing whitespace in .env no longer causes silent
auth failures (#35).

Closes #15, closes #35
This commit is contained in:
Артём Кокос
2026-06-25 21:06:19 +07:00
parent 3956decd4e
commit 3a6d1b7ba7
2 changed files with 26 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ from typing import Union
from dotenv import load_dotenv
load_dotenv()
load_dotenv(override=False)
DEFAULT_REDMINE_VERIFY = "/etc/ssl/certs/ca-certificates.crt"
FALSE_VALUES = {"0", "false", "no", "off"}
@@ -25,7 +25,7 @@ class Config:
@classmethod
def get_redmine_password(cls) -> str:
return os.getenv("REDMINE_PASSWORD", "")
return os.getenv("REDMINE_PASSWORD", "").strip()
@classmethod
def get_redmine_verify(cls) -> Union[bool, str]: