Skip to content

Commit 2a072c5

Browse files
committed
HOTFIX: AuthenticationError blocks API key auth fallback (OPE-91 root cause)
_validate_jwt caught AuthenticationError and raised HTTPException 401 immediately, preventing _validate_api_key from ever running. ci_ API keys hit verify_jwt -> fail local decode -> fall back to Supabase API call -> also fails -> raises AuthenticationError. The middleware treated this as a hard failure instead of allowing the API key path to try next. Fix: catch AuthenticationError and return None (same as InvalidTokenError). Root cause of all MCP 401 errors since day one.
1 parent 865c1fc commit 2a072c5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

backend/middleware/auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ def _validate_jwt(token: str) -> Optional[AuthContext]:
8888
except InvalidTokenError:
8989
# Could be a non-JWT token (API key) -- allow fallback
9090
return None
91-
except AuthenticationError as e:
92-
raise HTTPException(status_code=401, detail=str(e))
91+
except AuthenticationError:
92+
# Could be a non-JWT token (API key) -- allow fallback
93+
return None
9394
except Exception:
9495
return None
9596

0 commit comments

Comments
 (0)