From b3223025fa786b035ae837e93f86d9ebf1d74447 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Wed, 1 Apr 2026 14:02:08 -0700 Subject: [PATCH] fix(api): read STAGING_DB from env at call time in _user_yaml_path() Module-level DB_PATH is frozen at import time, so monkeypatch.setenv() in tests had no effect on _user_yaml_path(). Reading os.environ directly fixes 6 test_dev_api_settings PUT/POST failures in CI where /devl/job-seeker/ doesn't exist. --- dev-api.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dev-api.py b/dev-api.py index 8ccc0c3..761968c 100644 --- a/dev-api.py +++ b/dev-api.py @@ -963,9 +963,7 @@ def config_user(): # Try to read name from user.yaml if present try: import yaml - cfg_path = os.path.join(os.path.dirname(DB_PATH), "config", "user.yaml") - if not os.path.exists(cfg_path): - cfg_path = "/devl/job-seeker/config/user.yaml" + cfg_path = _user_yaml_path() with open(cfg_path) as f: cfg = yaml.safe_load(f) return {"name": cfg.get("name", "")} @@ -979,8 +977,9 @@ from scripts.user_profile import load_user_profile, save_user_profile def _user_yaml_path() -> str: - """Resolve user.yaml path, falling back to legacy location.""" - cfg_path = os.path.join(os.path.dirname(DB_PATH), "config", "user.yaml") + """Resolve user.yaml path relative to the current STAGING_DB location.""" + db = os.environ.get("STAGING_DB", "/devl/job-seeker/staging.db") + cfg_path = os.path.join(os.path.dirname(db), "config", "user.yaml") if not os.path.exists(cfg_path): cfg_path = "/devl/job-seeker/config/user.yaml" return cfg_path