Skip to content

[P1][bug] formatParamValue returns invalid SQL for typed input that fails numeric/date parsing #398

Closed

Description

@EVWorth

Context

Routine Viewer parameter input execution.

Problem

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

  1. CREATE FUNCTION foo(x INT) RETURNS INT RETURN x + 1
  2. Routine Viewer for foo
  3. Type "123abc" in x input
  4. 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.

Needs human verify

no

Doc drift

no

Activity

  1. added
    audit
    severity/p1
    kind/bug
    area/routine
    on Jul 31, 2026
  2. EVWorth commented on Sep 12, 2026

    @EVWorth
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/routineauditkind/bugseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions