mucahitkantepe commited on
Commit
2ba670a
·
1 Parent(s): 16ad21f

handle null string fields in product serialization

Browse files
Files changed (1) hide show
  1. backend/app/routers/products.py +6 -0
backend/app/routers/products.py CHANGED
@@ -60,6 +60,12 @@ def _row_to_product(row) -> ProductOut:
60
  if d.get("score") is None:
61
  d["score"] = 0
62
 
 
 
 
 
 
 
63
  return ProductOut(**d)
64
 
65
 
 
60
  if d.get("score") is None:
61
  d["score"] = 0
62
 
63
+ # Ensure string fields are never None
64
+ for str_field in ("brand", "name", "color", "material", "category", "price_text",
65
+ "currency", "image_url", "url", "store", "external_id"):
66
+ if d.get(str_field) is None:
67
+ d[str_field] = ""
68
+
69
  return ProductOut(**d)
70
 
71