Merge pull request #1759 from antonvice/bugfix/handle-none-filepath
Browse filesFix: Handle NoneType error when processing documents without a file path
- lightrag/lightrag.py +9 -3
lightrag/lightrag.py
CHANGED
@@ -900,9 +900,15 @@ class LightRAG:
|
|
900 |
# Get first document's file path and total count for job name
|
901 |
first_doc_id, first_doc = next(iter(to_process_docs.items()))
|
902 |
first_doc_path = first_doc.file_path
|
903 |
-
|
904 |
-
|
905 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
906 |
total_files = len(to_process_docs)
|
907 |
job_name = f"{path_prefix}[{total_files} files]"
|
908 |
pipeline_status["job_name"] = job_name
|
|
|
900 |
# Get first document's file path and total count for job name
|
901 |
first_doc_id, first_doc = next(iter(to_process_docs.items()))
|
902 |
first_doc_path = first_doc.file_path
|
903 |
+
|
904 |
+
# Handle cases where first_doc_path is None
|
905 |
+
if first_doc_path:
|
906 |
+
path_prefix = first_doc_path[:20] + (
|
907 |
+
"..." if len(first_doc_path) > 20 else ""
|
908 |
+
)
|
909 |
+
else:
|
910 |
+
path_prefix = "unknown_source"
|
911 |
+
|
912 |
total_files = len(to_process_docs)
|
913 |
job_name = f"{path_prefix}[{total_files} files]"
|
914 |
pipeline_status["job_name"] = job_name
|