Merge pull request #1759 from antonvice/bugfix/handle-none-filepath

Fix: Handle NoneType error when processing documents without a file path
This commit is contained in:
Daniel.y 2025-07-09 09:21:04 +08:00 committed by GitHub
commit feb30d8987
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -900,9 +900,15 @@ class LightRAG:
# Get first document's file path and total count for job name
first_doc_id, first_doc = next(iter(to_process_docs.items()))
first_doc_path = first_doc.file_path
path_prefix = first_doc_path[:20] + (
"..." if len(first_doc_path) > 20 else ""
)
# Handle cases where first_doc_path is None
if first_doc_path:
path_prefix = first_doc_path[:20] + (
"..." if len(first_doc_path) > 20 else ""
)
else:
path_prefix = "unknown_source"
total_files = len(to_process_docs)
job_name = f"{path_prefix}[{total_files} files]"
pipeline_status["job_name"] = job_name