You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] formatParamValue returns invalid SQL for typed input that fails numeric/date parsing #398
src/components/routine/RoutineViewer.tsx:528-540 (formatParamValue) — for an INT param, formatParamValue("123abc", "INT") does Number("123abc") = NaN, isNaN(num) === true, so falls through to the string branch: '123abc' -> MySQL rejects with ERROR 1366 (HY000): Incorrect integer value. For DATE param, formatParamValue("not-a-date", "DATE") returns 'not-a-date' -> ERROR 1292 (22007): Incorrect date value. User sees the execute error but the input field has no inline validation.
Files
src/components/routine/RoutineViewer.tsx:528-540
Repro
CREATE FUNCTION foo(x INT) RETURNS INT RETURN x + 1
Routine Viewer for foo
Type "123abc" in x input
Click Execute — MySQL returns error 1366
Expected
Typing 123abc into an INT input shows an inline error "Must be an integer" and the Execute button is disabled.
Proposed fix
Add client-side per-type validation: regex for INT family, FLOAT/DOUBLE/DECIMAL, DATE, etc. Render an inline error below the input. Disable the Execute button while any input is invalid. Scope: M.
Acceptance
Typing 123abc into an INT input shows an inline error and the Execute button is disabled.
Closed by #653, with a note on what the fix turned out to be.
The described failure — formatParamValue("123abc", "INT") reaching MySQL and returning error 1366 — no longer happened: the function refuses a value the type cannot hold, so the error came from the app. But it still came after clicking Execute, which is what this issue is really about.
The worse bug was one step upstream. Numeric parameters used type="number". A number input reads back "" for anything the browser cannot parse, and this dialog sends an empty value as NULL — so a mistyped id did not produce an error at all, it produced a call with no id. Silently. The spinner also rounds a BIGINT past 2^53, which is the precision that type exists for.
Exact numerics now get a text box with inputMode="numeric", so the value the user typed is the value that gets checked and nothing is discarded on the way. The check runs as they type, with the reason under the input, aria-invalid set, and Execute disabled while any value is wrong — your acceptance criterion.
One addition beyond it: a test that runs a range of inputs through both the validator and the execute path and asserts they agree. Those two drifting apart is the usual failure mode of client-side validation, and it would show up as Execute being disabled for a value that would have worked.
Activity
fix(routine): close the parameter injection, and put DROP behind the …
EVWorth commentedon Sep 12, 2026
Closed by #653, with a note on what the fix turned out to be.
The described failure —
formatParamValue("123abc", "INT")reaching MySQL and returning error 1366 — no longer happened: the function refuses a value the type cannot hold, so the error came from the app. But it still came after clicking Execute, which is what this issue is really about.The worse bug was one step upstream. Numeric parameters used
type="number". A number input reads back""for anything the browser cannot parse, and this dialog sends an empty value as NULL — so a mistyped id did not produce an error at all, it produced a call with no id. Silently. The spinner also rounds a BIGINT past 2^53, which is the precision that type exists for.Exact numerics now get a text box with
inputMode="numeric", so the value the user typed is the value that gets checked and nothing is discarded on the way. The check runs as they type, with the reason under the input,aria-invalidset, and Execute disabled while any value is wrong — your acceptance criterion.One addition beyond it: a test that runs a range of inputs through both the validator and the execute path and asserts they agree. Those two drifting apart is the usual failure mode of client-side validation, and it would show up as Execute being disabled for a value that would have worked.