LHF: seriesLimit input can produce NaN #13

Open
opened 2026-06-05 10:22:38 +00:00 by sebse · 0 comments
Owner

Low-Hanging Fruit

File: web/components/ChartEditor.tsx

The seriesLimit input uses Number(e.target.value) which can produce NaN if the input is empty or non-numeric:

onChange={(e) => setSeriesLimit(Number(e.target.value))}

Impact

If user clears the input, seriesLimit becomes 0 or NaN, which gets sent to the API. The DB column is integer NOT NULL DEFAULT 20, so a 0 would pass through.

Fix

onChange={(e) => {
  const v = parseInt(e.target.value, 10);
  setSeriesLimit(isNaN(v) ? 1 : Math.max(1, Math.min(200, v)));
}}

Effort

2 minutes.

## Low-Hanging Fruit **File:** `web/components/ChartEditor.tsx` The `seriesLimit` input uses `Number(e.target.value)` which can produce NaN if the input is empty or non-numeric: ```tsx onChange={(e) => setSeriesLimit(Number(e.target.value))} ``` ### Impact If user clears the input, `seriesLimit` becomes `0` or `NaN`, which gets sent to the API. The DB column is `integer NOT NULL DEFAULT 20`, so a 0 would pass through. ### Fix ```tsx onChange={(e) => { const v = parseInt(e.target.value, 10); setSeriesLimit(isNaN(v) ? 1 : Math.max(1, Math.min(200, v))); }} ``` ### Effort 2 minutes.
sebse added the low-hanging-fruit label 2026-06-05 10:22:38 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sebse/factorio-signal-exporter#13