diff --git a/lightrag/kg/json_doc_status_impl.py b/lightrag/kg/json_doc_status_impl.py index df6502ee..8b9302a8 100644 --- a/lightrag/kg/json_doc_status_impl.py +++ b/lightrag/kg/json_doc_status_impl.py @@ -113,8 +113,8 @@ class JsonDocStatusStorage(DocStatusStorage): data = v.copy() # Remove deprecated content field if it exists data.pop("content", None) - # If file_path is not in data, use document id as file path - if "file_path" not in data: + # If file_path is missing or null, use placeholder value + if data.get("file_path") is None: data["file_path"] = "no-file-path" # Ensure new fields exist with default values if "metadata" not in data: @@ -142,8 +142,8 @@ class JsonDocStatusStorage(DocStatusStorage): data = v.copy() # Remove deprecated content field if it exists data.pop("content", None) - # If file_path is not in data, use document id as file path - if "file_path" not in data: + # If file_path is missing or null, use placeholder value + if data.get("file_path") is None: data["file_path"] = "no-file-path" # Ensure new fields exist with default values if "metadata" not in data: @@ -274,7 +274,7 @@ class JsonDocStatusStorage(DocStatusStorage): # Prepare document data data = doc_data.copy() data.pop("content", None) - if "file_path" not in data: + if data.get("file_path") is None: data["file_path"] = "no-file-path" if "metadata" not in data: data["metadata"] = {} diff --git a/lightrag/kg/mongo_impl.py b/lightrag/kg/mongo_impl.py index e6ca5f5c..45a7b4eb 100644 --- a/lightrag/kg/mongo_impl.py +++ b/lightrag/kg/mongo_impl.py @@ -294,8 +294,8 @@ class MongoDocStatusStorage(DocStatusStorage): data.pop("content", None) # Remove MongoDB _id field if it exists data.pop("_id", None) - # If file_path is not in data, use document id as file path - if "file_path" not in data: + # If file_path is missing or null, use placeholder value + if data.get("file_path") is None: data["file_path"] = "no-file-path" # Ensure new fields exist with default values if "metadata" not in data: diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 1fd76276..e2473c14 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -3643,6 +3643,10 @@ class PGDocStatusStorage(DocStatusStorage): created_at = self._format_datetime_with_timezone(element["created_at"]) updated_at = self._format_datetime_with_timezone(element["updated_at"]) + file_path = element.get("file_path") + if file_path is None: + file_path = "no-file-path" + doc_status = DocProcessingStatus( content_summary=element["content_summary"], content_length=element["content_length"], @@ -3650,7 +3654,7 @@ class PGDocStatusStorage(DocStatusStorage): created_at=created_at, updated_at=updated_at, chunks_count=element["chunks_count"], - file_path=element["file_path"], + file_path=file_path, chunks_list=chunks_list, track_id=element.get("track_id"), metadata=metadata, diff --git a/lightrag/kg/redis_impl.py b/lightrag/kg/redis_impl.py index d2030c3e..568a4197 100644 --- a/lightrag/kg/redis_impl.py +++ b/lightrag/kg/redis_impl.py @@ -754,8 +754,8 @@ class RedisDocStatusStorage(DocStatusStorage): data = doc_data.copy() # Remove deprecated content field if it exists data.pop("content", None) - # If file_path is not in data, use document id as file path - if "file_path" not in data: + # If file_path is missing or null, use placeholder value + if data.get("file_path") is None: data["file_path"] = "no-file-path" # Ensure new fields exist with default values if "metadata" not in data: @@ -810,8 +810,8 @@ class RedisDocStatusStorage(DocStatusStorage): data = doc_data.copy() # Remove deprecated content field if it exists data.pop("content", None) - # If file_path is not in data, use document id as file path - if "file_path" not in data: + # If file_path is missing or null, use placeholder value + if data.get("file_path") is None: data["file_path"] = "no-file-path" # Ensure new fields exist with default values if "metadata" not in data: @@ -977,7 +977,7 @@ class RedisDocStatusStorage(DocStatusStorage): # Prepare document data data = doc_data.copy() data.pop("content", None) - if "file_path" not in data: + if data.get("file_path") is None: data["file_path"] = "no-file-path" if "metadata" not in data: data["metadata"] = {}