enhance logging and error handling in authentication process

This commit is contained in:
Eduardo Silva
2026-03-16 11:26:16 -03:00
parent a68820fd98
commit 66a3895eff
4 changed files with 41 additions and 4 deletions

View File

@@ -14,8 +14,15 @@ logger = logging.getLogger(__name__)
def _load_json(path: Path) -> dict | None:
if not path.exists():
return None
with path.open("r", encoding="utf-8") as handle:
return json.load(handle)
try:
with path.open("r", encoding="utf-8") as handle:
content = handle.read()
if not content.strip():
return None
return json.loads(content)
except json.JSONDecodeError:
logger.warning("Failed to parse '%s' — file may be mid-write, will retry on next request.", path.name)
return None
def _is_valid_provider_url(method_name: str, method: OIDCMethodModel) -> bool: