Skip to content

🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!

Reject whitespace-only product names on warranty create/update

Omega (QA)7fe84e777a92
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f9ed76..0c34665 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,8 @@
- _Files: `frontend/js/components/tagManager.js`_
### Fixed
+- **Whitespace-only product names now rejected:** a name of only spaces passed the "required" check and was stored verbatim; create and update now validate the stripped value.
+ - _Files: `backend/warranties_routes.py`
- **Oversized CSV fields now return 400 instead of 500:** a single CSV cell over 128KB raised `csv.Error: field larger than field limit`, which fell into the generic import handler as HTTP 500. CSV parse errors now return a clean 400 (`csv_field_too_large`).
- _Files: `backend/warranties_routes.py`
- **Total Value card no longer sums across currencies (issue #192):** the `/statistics` and `/statistics/global` endpoints summed `purchase_price` across all currencies into one number while the card displays the user's default-currency symbol. Both now filter to the requesting user's default currency (via a backend symbol→code map mirroring the frontend's `getCurrencyCode()`).
diff --git a/backend/warranties_routes.py b/backend/warranties_routes.py
index b779c82..ba4b95f 100644
--- a/backend/warranties_routes.py
+++ b/backend/warranties_routes.py
@@ -228,7 +228,7 @@ def add_warranty():
conn = None
try:
# Validate input data
- if not request.form.get('product_name'):
+ if not request.form.get('product_name', '').strip():
return jsonify({"error": "Product name is required"}), 400
if len(request.form.get('product_name')) > 255:
@@ -688,7 +688,7 @@ def update_warranty(warranty_id):
# --- Otherwise, continue with the original (form-based) update logic ---
# Validate input data similar to the add_warranty route
- if not request.form.get('product_name'):
+ if not request.form.get('product_name', '').strip():
return jsonify({"error": "Product name is required"}), 400
if len(request.form.get('product_name')) > 255:
return jsonify({"error": "Product name must be 255 characters or less",