From b0287f1b1046381d8f0853e2e44da3f6629516c6 Mon Sep 17 00:00:00 2001 From: jwed Date: Sat, 1 Aug 2026 17:05:14 -0400 Subject: [PATCH] Bound session_minutes to its column so an oversized value 422s (#5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `unifi_vlan_mappings.session_minutes` is `unsignedInteger` (ceiling 4294967295) but the mapping validator only said `integer|min:1`. Anything larger reached the INSERT and raised SQLSTATE 22003, so the request died as an unhandled 500 where a validation error belongs — the same shape just fixed in central-oncall#7. Adds `max:525600` (a year of minutes) to both storeMapping and updateMapping. Found while fixing #5, which reported a *silent* rejection rather than a crash. The VLAN ID validation the issue was actually about was already correct on the server (`min:1|max:4094` on all three forms); what was missing was any way to see it, and that half of the fix is in the shell's Unifi/Portal.vue. Sibling numeric fields were checked at the same time: `vlan_id` (unsignedSmallInteger, bounded 1–4094) and `max_devices` (unsignedTinyInteger, bounded 1–50) were already safe against their columns; `session_minutes` was the only one that could overflow. Version 1.13.3 -> 1.13.4. Test: dashboard-shell tests/Feature/Unifi/VlanGroupValidationTest.php Co-Authored-By: Claude --- composer.json | 2 +- src/Http/Controllers/PortalController.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index fb7e942..ce2dd9e 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "dashboard/unifi", "description": "UniFi network management, WiFi stats, and captive portal authentication for the Dashboard platform", - "version": "1.13.3", + "version": "1.13.4", "type": "library", "license": "MIT", "autoload": { diff --git a/src/Http/Controllers/PortalController.php b/src/Http/Controllers/PortalController.php index c970038..3501c13 100644 --- a/src/Http/Controllers/PortalController.php +++ b/src/Http/Controllers/PortalController.php @@ -36,7 +36,11 @@ class PortalController extends Controller 'match_value' => 'required|string|max:255', 'vlan_id' => 'required|integer|min:1|max:4094', 'max_devices' => 'required|integer|min:1|max:50', - 'session_minutes' => 'required|integer|min:1', + // Bounded by the column that stores it: unifi_vlan_mappings.session_minutes + // is unsignedInteger, so an unbounded value reached the INSERT and raised + // SQLSTATE 22003 — a 500 where a validation error belongs (central-unifi#5). + // 525600 minutes is a year, far more session than anyone will ever grant. + 'session_minutes' => 'required|integer|min:1|max:525600', ]); $data['sort_order'] = VlanMapping::max('sort_order') + 1; VlanMapping::create($data); @@ -51,7 +55,11 @@ class PortalController extends Controller 'match_value' => 'required|string|max:255', 'vlan_id' => 'required|integer|min:1|max:4094', 'max_devices' => 'required|integer|min:1|max:50', - 'session_minutes' => 'required|integer|min:1', + // Bounded by the column that stores it: unifi_vlan_mappings.session_minutes + // is unsignedInteger, so an unbounded value reached the INSERT and raised + // SQLSTATE 22003 — a 500 where a validation error belongs (central-unifi#5). + // 525600 minutes is a year, far more session than anyone will ever grant. + 'session_minutes' => 'required|integer|min:1|max:525600', ]); $mapping->update($data); return back()->with('success', 'Mapping updated.');