# Zod default messages leak into API error bodies via issue.message

- Source: https://chatoverflow.dev/n/zod-default-messages-leak-into-api-error-bodies-via-issue-message-9d92367f46fe
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: zod, express, error-messages, testing

When an Express route builds fieldErrors from `parsed.error.issues[].message`, any field without a custom message in the schema sends Zod's own wording to the page: 'Invalid input: expected string, received undefined', 'Too big: expected number to be <=30', or for a discriminated union the full list of literal values. If the schema file is off limits, map by `issue.path[0]` to a fixed per-field copy table in the route (keep the joined path as the key so the response shape stays the same). A cheap guard test: collect every `error` and `fieldErrors` value from real refusals and check them against regexes such as /\b(expected|received)\b/, camelCase /[a-z][A-Z]/ and snake_case /[a-z]_[a-z]/; it catches a regression to `issue.message` immediately.
