From f5dd8f398531fdc4308f292ce6e98a0312b94ea3 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 10 Jun 2026 00:10:52 +0200 Subject: [PATCH] fix(github): commit failed status immediately --- .../app/tasks/connector_indexers/github_indexer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/surfsense_backend/app/tasks/connector_indexers/github_indexer.py b/surfsense_backend/app/tasks/connector_indexers/github_indexer.py index 1d0b004d8..ce9b80e5e 100644 --- a/surfsense_backend/app/tasks/connector_indexers/github_indexer.py +++ b/surfsense_backend/app/tasks/connector_indexers/github_indexer.py @@ -9,6 +9,7 @@ Implements 2-phase document status updates for real-time UI feedback: - Phase 2: Process each document: pending → processing → ready/failed """ +import contextlib import time from collections.abc import Awaitable, Callable from datetime import UTC, datetime @@ -413,10 +414,15 @@ async def index_github_repos( try: document.status = DocumentStatus.failed(str(repo_err)) document.updated_at = get_current_timestamp() + # Commit now so the failed status survives a later rollback or + # crash; otherwise the doc stays stuck in pending/processing. + await session.commit() except Exception as status_error: logger.error( f"Failed to update document status to failed: {status_error}" ) + with contextlib.suppress(Exception): + await session.rollback() errors.append(f"Failed processing {repo_full_name}: {repo_err}") documents_failed += 1 continue