From b2c2fc9c2e4f49567227011771e4c61079227c0c Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 10 Jun 2026 00:10:42 +0200 Subject: [PATCH] fix(gmail): fail skipped placeholders so they don't stay pending --- .../connector_indexers/google_gmail_indexer.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/surfsense_backend/app/tasks/connector_indexers/google_gmail_indexer.py b/surfsense_backend/app/tasks/connector_indexers/google_gmail_indexer.py index 225e3618e..25da96b61 100644 --- a/surfsense_backend/app/tasks/connector_indexers/google_gmail_indexer.py +++ b/surfsense_backend/app/tasks/connector_indexers/google_gmail_indexer.py @@ -29,6 +29,7 @@ from .base import ( check_duplicate_document_by_hash, get_connector_by_id, logger, + mark_connector_documents_failed, update_connector_last_indexed, ) @@ -479,6 +480,23 @@ async def index_google_gmail_messages( heartbeat_interval=HEARTBEAT_INTERVAL_SECONDS, ) + # Placeholders for items skipped above (empty/duplicate/unbuildable) would + # otherwise stay stuck in 'pending' and undeletable. Fail them so they're + # recoverable. Leaves already-ready docs untouched. + indexed_ids = {doc.unique_id for doc in connector_docs} + stuck_placeholders = [ + (p.unique_id, "Skipped during sync: no indexable content") + for p in placeholders + if p.unique_id and p.unique_id not in indexed_ids + ] + if stuck_placeholders: + await mark_connector_documents_failed( + session, + document_type=DocumentType.GOOGLE_GMAIL_CONNECTOR, + search_space_id=search_space_id, + failures=stuck_placeholders, + ) + # ── Finalize ────────────────────────────────────────────────── await update_connector_last_indexed(session, connector, update_last_indexed)