Skip to content

docs: error message example in README doesn't match actual output #6589

Closed

Description

@phebiannwokeji-cmd

The 'Handling errors' section of packages/zod/README.md shows the Zod Error. issues messages as 'Invalid input: expected string' and 'Invalid input: expected number'. Running the exact example against the published package (zod 4.6.2) actually produces 'Invalid input: expected string, received number' and 'Invalid input: expected number, received string' — both messages are missing the ', received X' suffix. I have a two-line fix ready and a branch pushed to my fork (phebiannwokeji-cmd/zod, branch patch-1) if that's useful, but wanted to open this first per the CONTRIBUTING guide.

Activity

  1. pullfrog commented on Sep 11, 2026

    @pullfrog
    Contributor

    good-idea — the report is correct and actionable. I reproduced the mismatch against both current main and published zod@4.6.2; the similarity candidates concern different error-reporting behavior, so this is not a duplicate.

    import * as z from "zod";
    
    const Player = z.object({
      username: z.string(),
      xp: z.number(),
    });
    
    const result = Player.safeParse({ username: 42, xp: "100" });
    if (!result.success) {
      result.error.issues.map((issue) => issue.message);
      // actual: [
      //   "Invalid input: expected string, received number",
      //   "Invalid input: expected number, received string",
      // ]
      // README currently omits both `, received …` suffixes.
    }

    Plan:

    1. Update the two message strings in packages/zod/README.md so they include , received number and , received string. The root README.md is a symlink to this file, so no second edit is needed.
    2. Rerun the exact example against current source and compare the documented issue objects with the runtime output. This is documentation-only, and the repository does not execute README code blocks, so no implementation or test-suite changes are needed.

    No implementation was started. The detailed triage record is in .triage/issues/6589/results.md.

    Pullfrog  | Implement plan ➔ | View workflow run | via Pullfrog | Using GPT Sol | 𝕏

  2. colinhacks commented on Sep 11, 2026

    @colinhacks
    Owner

    Good catch. Fixed in 46da957.

    The same stale strings were on the Basics docs page too, and the Zod Mini tab needed a different value again — @zod/mini ships without the en locale, so it emits a bare Invalid input until you configure one. Six occurrences in total, so I took it directly rather than have you chase them all down.

    Thanks for the report! 👍

  3. added a commit that references this issue on Sep 11, 2026
    46da957
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