fix: suppress only baton error #102

Merged
perl_d merged 1 commits from fix/suppress_baton_error into master 2026-07-09 16:25:26 +02:00
+7
View File
@@ -36,6 +36,7 @@ from aarecommon.errors.exception_handler import (
AareUserError,
AuthenticationException,
AutomationError,
UserRightsException,
)
from fastapi import HTTPException
from fastapi import status as api_status
@@ -171,6 +172,12 @@ def register_exception_handlers(app) -> None:
else api_status.HTTP_403_FORBIDDEN
)
body = _error_body(exc, code_override=code_override)
# TODO: migrate baton to its own error type
if isinstance(exc, UserRightsException):
if "do not hold the baton" in exc.message:
return JSONResponse(
status_code=status, content=body, headers=getattr(exc, "headers", None)
)
logger.warning(
"AareAuthError: %s",
body["message"],