fix(auth): credential audit reads profile config.yaml through read_user_config_raw

The config read guard flags bare yaml.safe_load of config.yaml outside the owner modules; the
audit is a raw-file diagnostic over another profile's file, which is exactly what
read_user_config_raw exists for.
This commit is contained in:
teknium1
2026-09-16 14:24:58 -07:00
committed by Teknium
parent 93889b770d
commit 8c8003f80b

View File

@@ -43,12 +43,13 @@ def _profile_has_own_credentials(profile_dir: Path) -> bool:
provider_env_vars.update(pconfig.api_key_env_vars)
if _dotenv_has_provider_key(profile_dir / ".env", provider_env_vars):
return True
# Raw-file diagnostic over another profile's config.yaml: the owner API, not a bare yaml load.
from hermes_cli.config import read_user_config_raw
try:
import yaml
cfg = yaml.safe_load((profile_dir / "config.yaml").read_text(encoding="utf-8")) or {}
cfg = read_user_config_raw(profile_dir / "config.yaml")
except Exception:
return False
model_cfg = cfg.get("model") if isinstance(cfg, dict) else None
model_cfg = cfg.get("model")
return isinstance(model_cfg, dict) and any(
str(model_cfg.get(k) or "").strip() for k in ("base_url", "api_key"))