Skip to content

Commit 0577765

Browse files
committed
Ensure all crawls actually exist
1 parent f26b176 commit 0577765

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
@@ -613,12 +613,11 @@ async def bulk_presigned_files(
613613
return resources, pages_optimized
614614

615615
async def validate_all_crawls_successful(self, crawl_ids: List[str]):
616-
"""Validate that no crawls in list failed or else raise exception"""
617-
result = await self.crawls.find_one(
618-
{"_id": {"$in": crawl_ids}, "state": {"$in": FAILED_STATES}}
619-
)
620-
if result:
621-
raise HTTPException(status_code=400, detail="invalid_failed_crawl")
616+
"""Validate that crawls in list exist and are successful or else raise exception"""
617+
for crawl_id in crawl_ids:
618+
crawl = await self.get_base_crawl(crawl_id)
619+
if crawl.state in FAILED_STATES:
620+
raise HTTPException(status_code=400, detail="invalid_failed_crawl")
622621

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

0 commit comments

Comments
 (0)