add error handling for policy configuration issues in authentication

This commit is contained in:
Eduardo Silva
2026-03-16 14:16:28 -03:00
parent e1f128f217
commit c707d278f3
5 changed files with 11 additions and 6 deletions

View File

@@ -84,11 +84,9 @@ def load_runtime_config(config_dir: Path) -> RuntimeConfig:
raise ValueError(f"Policy '{policy_name}' references unknown group '{group_name}'.")
for method_name in policy.methods:
if method_name not in auth.auth_methods:
logger.warning(
"Policy '%s' references unavailable method '%s' — policy forced to deny.",
policy_name, method_name,
)
auth.policies[policy_name] = PolicyModel(policy_type="deny")
msg = f"Policy '{policy_name}' references unavailable auth method '{method_name}'."
logger.error("CONFIG error: %s", msg)
auth.policies[policy_name] = PolicyModel(policy_type="error", error_message=msg)
break
return RuntimeConfig(