Skip to content

Commit f81efeb

Browse files
committed
Ensure all crawls actually exist
1 parent b7fab38 commit f81efeb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

backend/btrixcloud/basecrawls.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,11 @@ async def bulk_presigned_files(
603603
return resources, pages_optimized
604604

605605
async def validate_all_crawls_successful(self, crawl_ids: List[str]):
606-
"""Validate that no crawls in list failed or else raise exception"""
607-
result = await self.crawls.find_one(
608-
{"_id": {"$in": crawl_ids}, "state": {"$in": FAILED_STATES}}
609-
)
610-
if result:
611-
raise HTTPException(status_code=400, detail="invalid_failed_crawl")
606+
"""Validate that crawls in list exist and are successful or else raise exception"""
607+
for crawl_id in crawl_ids:
608+
crawl = await self.get_base_crawl(crawl_id)
609+
if crawl.state in FAILED_STATES:
610+
raise HTTPException(status_code=400, detail="invalid_failed_crawl")
612611

613612
async def add_to_collection(
614613
self, crawl_ids: List[str], collection_id: UUID, org: Organization

0 commit comments

Comments
 (0)