diff --git a/domain/bulk_document_download/package_plan.py b/domain/bulk_document_download/package_plan.py index 64e57950d..bcd122aad 100644 --- a/domain/bulk_document_download/package_plan.py +++ b/domain/bulk_document_download/package_plan.py @@ -64,8 +64,17 @@ def plan_download_package( per property, the latest file of each Document Type, null-Document-Type rows skipped and reported.""" latest_by_group: dict[tuple[str, str], ResolvedDocument] = {} + skipped: list[SkippedDocument] = [] for document in documents: - assert document.document_type is not None + if document.document_type is None: + skipped.append( + SkippedDocument( + landlord_property_id=document.landlord_property_id, + s3_key=document.s3_key, + reason="null_document_type", + ) + ) + continue group = (document.landlord_property_id, document.document_type) incumbent = latest_by_group.get(group) if incumbent is None or document.uploaded_at > incumbent.uploaded_at: @@ -80,4 +89,4 @@ def plan_download_package( ) for document in latest_by_group.values() ] - return DownloadPackagePlan(entries=tuple(entries), skipped=()) + return DownloadPackagePlan(entries=tuple(entries), skipped=tuple(skipped))