Fix response model for crawl errors API endpoint (#1939)

Follow-up fix for #1920 for crawl errors endpoint, which returns a 500
following #1928, caught in nightly tests.
This commit is contained in:
Tessa Walsh 2024-07-17 13:52:14 -04:00 committed by GitHub
parent 335700e683
commit c772ee2362
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -41,6 +41,7 @@ from .models import (
User,
PaginatedCrawlOutResponse,
PaginatedSeedResponse,
PaginatedCrawlErrorResponse,
RUNNING_AND_STARTING_STATES,
SUCCESSFUL_STATES,
NON_RUNNING_STATES,
@ -1471,7 +1472,9 @@ def init_crawls_api(crawl_manager: CrawlManager, app, user_dep, *args):
raise HTTPException(status_code=400, detail="crawl_not_finished")
@app.get(
"/orgs/{oid}/crawls/{crawl_id}/errors", tags=["crawls"], response_model=bytes
"/orgs/{oid}/crawls/{crawl_id}/errors",
tags=["crawls"],
response_model=PaginatedCrawlErrorResponse,
)
async def get_crawl_errors(
crawl_id: str,

View File

@ -930,6 +930,17 @@ class CrawlScaleResponse(BaseModel):
scaled: int
# ============================================================================
class CrawlError(BaseModel):
"""Crawl error"""
timestamp: str
logLevel: str
context: str
message: str
details: Any
# ============================================================================
### UPLOADED CRAWLS ###
@ -2223,3 +2234,10 @@ class PaginatedWebhookNotificationResponse(PaginatedResponse):
"""Response model for paginated webhook notifications"""
items: List[WebhookNotification]
# ============================================================================
class PaginatedCrawlErrorResponse(PaginatedResponse):
"""Response model for crawl errors"""
items: List[CrawlError]