Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: track failed text extractions by creating Document records (#2590)

LearningCircuit1b590d656933
diff --git a/src/local_deep_research/research_library/services/download_service.py b/src/local_deep_research/research_library/services/download_service.py
index f36398a96d..70d11495f9 100644
--- a/src/local_deep_research/research_library/services/download_service.py
+++ b/src/local_deep_research/research_library/services/download_service.py
@@ -1574,6 +1574,9 @@ class DownloadService:
doc.word_count = word_count
doc.extraction_method = extraction_method
doc.extraction_source = extraction_source
+ doc.status = DocumentStatus.COMPLETED
+ doc.document_hash = hashlib.sha256(text.encode()).hexdigest()
+ doc.processed_at = datetime.now(UTC)
# Set quality based on method
if extraction_method == "native_api":
@@ -1722,12 +1725,57 @@ class DownloadService:
doc.error_message = error
doc.extraction_method = "failed"
doc.extraction_quality = "low"
+ doc.status = DocumentStatus.FAILED
logger.info(
f"Recorded failed text extraction for document {doc.id}: {error}"
)
else:
- logger.warning(
- f"No document found to record extraction failure for resource {resource.id}"
+ # Create a new Document for failed extraction
+ # This enables tracking failures and retry capability
+ source_type_id = get_source_type_id(
+ self.username, "research_download", self.password
+ )
+
+ # Deterministic hash so retries update the same record
+ failed_hash = hashlib.sha256(
+ f"failed:{resource.url}:{resource.id}".encode()
+ ).hexdigest()
+
+ doc_id = str(uuid.uuid4())
+ doc = Document(
+ id=doc_id,
+ source_type_id=source_type_id,
+ resource_id=resource.id,
+ research_id=resource.research_id,
+ document_hash=failed_hash,
+ original_url=resource.url,
+ file_path=None,
+ file_size=0,
+ file_type="unknown",
+ title=resource.title,
+ status=DocumentStatus.FAILED,
+ error_message=error,
+ extraction_method="failed",
+ extraction_quality="low",
+ processed_at=datetime.now(UTC),
+ )
+ session.add(doc)
+
+ # Link to Library collection
+ library_collection = (
+ session.query(Collection).filter_by(name="Library").first()
+ )
+ if library_collection:
+ doc_collection = DocumentCollection(
+ document_id=doc_id,
+ collection_id=library_collection.id,
+ indexed=False,
+ chunk_count=0,
+ )
+ session.add(doc_collection)
+
+ logger.info(
+ f"Created failed document {doc_id} for resource {resource.id}: {error}"
)
except Exception: