From e30f55b4e5029117c57cae57b454fe228560c01e Mon Sep 17 00:00:00 2001 From: bsiggel Date: Wed, 1 Apr 2026 12:06:50 +0000 Subject: [PATCH] fix: handle unsupported document types in RAGflow sync and improve logging --- src/steps/crm/akte/akte_sync_event_step.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/steps/crm/akte/akte_sync_event_step.py b/src/steps/crm/akte/akte_sync_event_step.py index dc90629..1d0549b 100644 --- a/src/steps/crm/akte/akte_sync_event_step.py +++ b/src/steps/crm/akte/akte_sync_event_step.py @@ -684,11 +684,17 @@ async def _run_ragflow_sync( ctx.logger.info( f" ⏭️ Nicht unterstützter Dateityp ({mime_type}) – übersprungen" ) - if not ragflow_doc_id: - await espocrm.update_entity('CDokumente', doc_id, { - 'aiSyncStatus': 'unsupported', - 'aiLastSync': datetime.now().strftime('%Y-%m-%d %H:%M:%S'), - }) + # If doc was previously uploaded to RAGflow (e.g. type changed), remove it + if ragflow_doc_id: + try: + await ragflow.remove_document(dataset_id, ragflow_doc_id) + ctx.logger.info(f" 🗑️ Aus RAGflow entfernt (nicht unterstützt): {ragflow_doc_id}") + except Exception as e: + ctx.logger.warn(f" ⚠️ RAGflow-Löschung fehlgeschlagen: {e}") + await espocrm.update_entity('CDokumente', doc_id, { + 'aiSyncStatus': 'unsupported', + 'aiLastSync': datetime.now().strftime('%Y-%m-%d %H:%M:%S'), + }) skipped += 1 continue