Jeremiah Lowin Claude commited on
Commit
1839cc8
·
1 Parent(s): b163829

Use specific ValidationError instead of broad Exception catch

Browse files

Addresses PR feedback to use more specific exception handling for
URL validation failures.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

src/fastmcp/server/auth/providers/bearer.py CHANGED
@@ -17,7 +17,7 @@ from mcp.shared.auth import (
17
  OAuthClientInformationFull,
18
  OAuthToken,
19
  )
20
- from pydantic import AnyHttpUrl, SecretStr
21
 
22
  from fastmcp.server.auth.auth import (
23
  ClientRegistrationOptions,
@@ -183,7 +183,7 @@ class BearerAuthProvider(OAuthProvider):
183
  # This allows the issuer claim validation to work with string issuers per RFC 7519
184
  try:
185
  issuer_url = AnyHttpUrl(issuer) if issuer else "https://fastmcp.example.com"
186
- except Exception:
187
  # Issuer is not a valid URL, use default for parent class
188
  issuer_url = "https://fastmcp.example.com"
189
 
 
17
  OAuthClientInformationFull,
18
  OAuthToken,
19
  )
20
+ from pydantic import AnyHttpUrl, SecretStr, ValidationError
21
 
22
  from fastmcp.server.auth.auth import (
23
  ClientRegistrationOptions,
 
183
  # This allows the issuer claim validation to work with string issuers per RFC 7519
184
  try:
185
  issuer_url = AnyHttpUrl(issuer) if issuer else "https://fastmcp.example.com"
186
+ except ValidationError:
187
  # Issuer is not a valid URL, use default for parent class
188
  issuer_url = "https://fastmcp.example.com"
189