fix: add bounded timeout to Firecrawl credential validation (#37638)

This commit is contained in:
Evan 2026-06-22 10:56:15 +08:00 committed by GitHub
parent 16fd55ab58
commit 89d4fe91bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,10 @@ import httpx
from services.auth.api_key_auth_base import ApiKeyAuthBase, AuthCredentials
# Explicit bounded timeout for credential-validation requests so a slow or
# hanging Firecrawl endpoint cannot block the worker indefinitely.
_CREDENTIAL_TIMEOUT = httpx.Timeout(10.0)
class FirecrawlAuth(ApiKeyAuthBase):
def __init__(self, credentials: AuthCredentials):
@ -42,7 +46,7 @@ class FirecrawlAuth(ApiKeyAuthBase):
return f"{self.base_url.rstrip('/')}/{path.lstrip('/')}"
def _post_request(self, url, data, headers):
return httpx.post(url, headers=headers, json=data)
return httpx.post(url, headers=headers, json=data, timeout=_CREDENTIAL_TIMEOUT)
def _handle_error(self, response):
try:

View File

@ -86,6 +86,7 @@ class TestFirecrawlAuth:
"https://api.firecrawl.dev/v1/crawl",
headers={"Content-Type": "application/json", "Authorization": "Bearer test_api_key_123"},
json=expected_data,
timeout=httpx.Timeout(10.0),
)
@pytest.mark.parametrize(