Skip to content

Commit 1b9a647

Browse files
Sihem TchabiSihem Tchabi
authored andcommitted
fix(LAB-3992): fix to ensure the json_metadatas is correct
1 parent 071e45d commit 1b9a647

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • src/kili/services/asset_import

src/kili/services/asset_import/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ def stringify_metadata(asset: AssetLike) -> AssetLike:
165165
"""Stringify the metadata."""
166166
json_metadata = asset.get("json_metadata", {})
167167
if not isinstance(json_metadata, str):
168-
json_metadata = dumps(json_metadata)
168+
try:
169+
json_metadata = dumps(json_metadata, allow_nan=False)
170+
except (ValueError, TypeError) as e:
171+
raise ValueError(
172+
f"Invalid json_metadata: cannot be serialized to valid JSON ({e})"
173+
) from e
169174
return {**asset, "json_metadata": json_metadata}
170175

171176
@staticmethod

0 commit comments

Comments
 (0)