From c772ee2362351654e3e943731a9478c3f1f19b68 Mon Sep 17 00:00:00 2001 From: Tessa Walsh Date: Wed, 17 Jul 2024 13:52:14 -0400 Subject: [PATCH] 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. --- backend/btrixcloud/crawls.py | 5 ++++- backend/btrixcloud/models.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/btrixcloud/crawls.py b/backend/btrixcloud/crawls.py index d1e6215b..7e8966e9 100644 --- a/backend/btrixcloud/crawls.py +++ b/backend/btrixcloud/crawls.py @@ -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, diff --git a/backend/btrixcloud/models.py b/backend/btrixcloud/models.py index 184df795..f1fc7ae9 100644 --- a/backend/btrixcloud/models.py +++ b/backend/btrixcloud/models.py @@ -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]