Skip to content

Commit db69945

Browse files
committed
HOTFIX: AuthenticationError blocks API key auth fallback (OPE-91 root cause)
_validate_jwt catches InvalidTokenError and returns None to allow the API key path to run. But AuthenticationError (raised when Supabase API verification also fails) was caught separately and raised HTTPException 401 immediately -- preventing _validate_api_key from ever executing. Non-JWT tokens like ci_ API keys hit verify_jwt, fail local decode, fall back to Supabase API call, which also fails and raises AuthenticationError. The middleware treated this as a hard auth failure instead of allowing the API key code path. Fix: catch AuthenticationError and return None, same as InvalidTokenError. This was the root cause of all MCP server 401 errors since day one.
1 parent 865c1fc commit db69945

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)