Handle null file_path in doc status storages
This commit is contained in:
@@ -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"] = {}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"] = {}
|
||||
|
||||
Reference in New Issue
Block a user