🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Return 400 instead of 500 for tag names over 50 characters
Omega (QA)5d413017831e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0587035..77be430 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,8 @@- _Files: `frontend/js/components/tagManager.js`_### Fixed+- **Tag create/rename 500 on names over 50 characters fixed:** `tags.name` is `varchar(50)`, but neither `POST /api/tags` nor `PUT /api/tags/<id>` validated length, so a 51+ character name escaped as HTTP 500. Both endpoints now return HTTP 400 up front. Found by the daily QA sweep.+ - _Files: `backend/tags_routes.py`- **`saveThemePreference is not defined` ReferenceError on status.html fixed:** the prefs loader in `script.js` called the global `saveThemePreference()`, which is only defined by the `js/lib/theme.js` ES module loaded on index.html. Every status-page load logged a console error and aborted the prefs sync, so saved filters, expiring-soon days, and date format were never written to localStorage there. The call is now guarded with a `typeof` check. Found by the daily QA sweep.- _Files: `frontend/script.js`- **Login/registration/password-change 500 on passwords over 72 bytes fixed:** bcrypt rejects passwords longer than 72 bytes with `ValueError`, which escaped as HTTP 500 on `/api/auth/login` (and latently on register and the password reset/change endpoints for strong long passwords). All four endpoints now check the byte length up front via a new `is_password_too_long()` helper and return HTTP 400. Found by the daily QA sweep.diff --git a/backend/tags_routes.py b/backend/tags_routes.pyindex ae197e4..fa68220 100644--- a/backend/tags_routes.py+++ b/backend/tags_routes.py@@ -74,7 +74,11 @@ def create_tag():if not name:return jsonify({"error": "Tag name cannot be empty"}), 400-++ # tags.name is varchar(50) — validate up front instead of surfacing a 500+ if len(name) > 50:+ return jsonify({"error": "Tag name must not exceed 50 characters"}), 400+# Validate color format (should be a hex color)if not re.match(r'^#[0-9A-Fa-f]{6}$', color):return jsonify({"error": "Invalid color format. Use hex format (e.g., #FF5733)"}), 400@@ -123,7 +127,11 @@ def update_tag(tag_id):if not new_name:return jsonify({"error": "Tag name cannot be empty"}), 400-++ # tags.name is varchar(50) — validate up front instead of surfacing a 500+ if len(new_name) > 50:+ return jsonify({"error": "Tag name must not exceed 50 characters"}), 400+# Validate color format (basic check)if new_color and not re.match(r'^#[0-9a-fA-F]{6}$', new_color):return jsonify({"error": "Invalid color format. Use hex (e.g., #RRGGBB)"}), 400