Skip to content

Bug: lt locale appends literal "undefined" to too_big/too_small messages for number, bigint, date and map #6655

Open

Description

@devin-ai-integration

Summary

The Lithuanian (lt) locale appends the literal word undefined to every too_big / too_small message whose origin has no size unit: number, bigint, date and map. When getSizing() returns null, the fallback branch still interpolates ${sizing?.unit}.

Reproduction

  1. npm i zod@4.6.6
  2. Run with node repro.mjs:
import * as z from "zod";
z.config(z.locales.lt());
console.log(z.number().max(5).safeParse(9).error.issues[0].message);
console.log(z.date().min(new Date(5)).safeParse(new Date(1)).error.issues[0].message);
console.log(z.bigint().max(5n).safeParse(9n).error.issues[0].message);
console.log(z.map(z.string(), z.number()).max(1).safeParse(new Map([["a", 1], ["b", 2]])).error.issues[0].message);
  1. The bug happens whenever issue.origin is missing from the locale's Sizable table (in lt that's everything except string, file, array and set).

Actual behavior

Skaičius turi būti ne didesnis kaip 5 undefined
Date turi būti ne mažesnis kaip 5 undefined
Sveikasis skaičius turi būti ne didesnis kaip 5 undefined
Map turi būti ne didesnis kaip 1 undefined

Expected behavior

There should be no trailing undefined. For example Skaičius turi būti ne didesnis kaip 5, which is what the other locales do in their fallback branch (e.g. en: Too big: expected number to be <=5).

Environment

  • Version/commit: zod 4.6.6 (npm), also present on main at 284243f
  • OS: Ubuntu Linux, Node v24.21.0
  • Relevant configuration: z.config(z.locales.lt())

Evidence

packages/zod/src/v4/locales/lt.ts lines 196 (too_big) and 209 (too_small):

return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.maximum.toString()} ${sizing?.unit}`;

sizing is null on this path (the sizing?.verb branch above it has already returned for sized origins), so ${sizing?.unit} always renders undefined.

Additional context

  • Confirmed: the reproduction above, run against the published 4.6.6 package. I swept every locale over ~45 failing schemas and lt was the only one that leaks undefined this way.
  • Likely fix (not tested in a PR): drop the ${sizing?.unit} suffix from both fallback returns.
  • Related but separate: v4: locales other than en ignore the exact flag on too_small / too_big #6406 (lt and other locales ignoring issue.exact). I found no existing issue or open PR for this bug.

Activity

  1. peralva commented on Oct 15, 2026

    @peralva

    PRs are limited to collaborators, so the fix is on my fork: main...peralva:zod:fix/lt-unsized-size-undefined

    It drops the ${sizing?.unit} suffix from both lt fallback returns, which are only reached when sizing is null. It also adds a sweep to the locale parity test that renders every locale's too_big/too_small messages for number, bigint and date and fails on any undefined. Against the old lt.ts it reports exactly the six lt cases, and no other locale leaks. Happy to open a PR once that's possible.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions