Handle null file_path in doc status storages
Some checks failed
Linting and Formatting / Linting and Formatting (push) Has been cancelled
Offline Unit Tests / Offline Tests (3.12) (push) Has been cancelled
Offline Unit Tests / Offline Tests (3.14) (push) Has been cancelled

This commit is contained in:
2026-01-15 19:01:19 -05:00
parent 7d00bf68fe
commit 94acbc6837
4 changed files with 17 additions and 13 deletions

View File

@@ -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"] = {}

View File

@@ -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:

View File

@@ -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,

View File

@@ -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"] = {}