🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Fix CSV import overlong product names and short-row crash
Omega (QA)8628690a92c7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a22b929..1ecec0c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,8 @@- _Files: `frontend/js/components/tagManager.js`_### Fixed+- **CSV import now validates overlong product names and tolerates short rows:** importing a CSV with a product name over 255 characters previously leaked the raw Postgres error (`value too long for type character varying(255)`); the row is now rejected with the clean `ProductName must be 255 characters or less.` message matching the REST API validation. Rows with fewer cells than headers previously crashed with `Internal processing error: 'NoneType' object has no attribute 'strip'` (DictReader fills missing cells with `None`); all field extractions now guard against `None`.+ - _Files: `backend/warranties_routes.py`- **Dead mobile menu button on most pages fixed:** every page renders the hamburger `.mobile-menu-toggle` button and the `#mobileMenuPanel` markup, but only settings-new.html loaded `mobile-menu.js` — tapping the menu on index, status, register, about, and the password-reset pages did nothing. The script is now included on all pages that render the toggle. Found by a dedicated mobile QA pass (390px viewport, touch): menu opens/closes via button, overlay, and Escape on every page; nav links navigate; no horizontal overflow; no new JS errors.- _Files: `frontend/index.html`, `frontend/status.html`, `frontend/register.html`, `frontend/about.html`, `frontend/reset-password.html`, `frontend/reset-password-request.html`- **Missing file download 500 fixed:** `GET /api/files/<missing>` returned HTTP 500 because `serve_file` let `send_from_directory`'s NotFound fall into the generic 500 handler. It now checks existence up front and returns a JSON 404 ("File not found"), matching the `/secure-file/` route. Non-owners still get 403 without leaking file existence. Found by the daily QA sweep.diff --git a/backend/warranties_routes.py b/backend/warranties_routes.pyindex bff7e97..1563642 100644--- a/backend/warranties_routes.py+++ b/backend/warranties_routes.py@@ -1254,28 +1254,30 @@ def import_warranties():try:# --- Data Extraction and Basic Validation ---- product_name = row.get('ProductName', '').strip()- purchase_date_str = row.get('PurchaseDate', '').strip()- is_lifetime_str = row.get('IsLifetime', 'false').strip().lower()+ product_name = (row.get('ProductName') or '').strip()+ purchase_date_str = (row.get('PurchaseDate') or '').strip()+ is_lifetime_str = (row.get('IsLifetime') or 'false').strip().lower()# New duration fields- warranty_duration_years_str = row.get('WarrantyDurationYears', '0').strip()- warranty_duration_months_str = row.get('WarrantyDurationMonths', '0').strip()- warranty_duration_days_str = row.get('WarrantyDurationDays', '0').strip()+ warranty_duration_years_str = (row.get('WarrantyDurationYears') or '0').strip()+ warranty_duration_months_str = (row.get('WarrantyDurationMonths') or '0').strip()+ warranty_duration_days_str = (row.get('WarrantyDurationDays') or '0').strip()- purchase_price_str = row.get('PurchasePrice', '').strip()- serial_numbers_str = row.get('SerialNumber', '').strip()- product_url = row.get('ProductURL', '').strip()- tags_str = row.get('Tags', '').strip() # Get Tags string- vendor = row.get('Vendor', '').strip() # Extract Vendor- warranty_type = row.get('WarrantyType', '').strip() # Extract Warranty Type- expiration_date_str = row.get('ExpirationDate', '').strip()- notes = row.get('Notes', '').strip() or None # Extract Notes- model_number = row.get('ModelNumber', '').strip() or None # Extract Model Number- currency_str = row.get('Currency', '').strip().upper() # Extract Currency+ purchase_price_str = (row.get('PurchasePrice') or '').strip()+ serial_numbers_str = (row.get('SerialNumber') or '').strip()+ product_url = (row.get('ProductURL') or '').strip()+ tags_str = (row.get('Tags') or '').strip() # Get Tags string+ vendor = (row.get('Vendor') or '').strip() # Extract Vendor+ warranty_type = (row.get('WarrantyType') or '').strip() # Extract Warranty Type+ expiration_date_str = (row.get('ExpirationDate') or '').strip()+ notes = (row.get('Notes') or '').strip() or None # Extract Notes+ model_number = (row.get('ModelNumber') or '').strip() or None # Extract Model Number+ currency_str = (row.get('Currency') or '').strip().upper() # Extract Currencyif not product_name:errors.append("ProductName is required.")+ if len(product_name) > 255:+ errors.append("ProductName must be 255 characters or less.")if not purchase_date_str:errors.append("PurchaseDate is required.")@@ -1324,7 +1326,7 @@ def import_warranties():# Calculate expiration date if validif not errors and not is_lifetime and purchase_date:- expiration_date_str = row.get('ExpirationDate', '').strip()+ expiration_date_str = (row.get('ExpirationDate') or '').strip()# Check if duration is zero and an exact expiration date is providedif (warranty_duration_years == 0 and