Skip to content

Upgrade to Zod package version 4 returns non-descriptive Invalid input for invalid URL #618

@fr33bits

Description

@fr33bits

Before the Zod package version 4.0.5 upgrade (when Zod v4 was still used with the zod/v4 import), URL form fields would work normally and filling out an invalid URL would return the error Invalid URL.

After upgrading the package version (and the imports from zod/v4 to zod, though the issue remains even if that step is skipped), the error for an invalid URL is returned as Invalid input, which does not signal that something is wrong with the URL format per se.

This does not appear to be an issue with Zod itself as the same schema is also used for an API, which returns specific error messages as well and there Invalid URL remains as the correct error message.

Can be trialed out in this MRE with https://host name as the URL input to trigger the error while passing the HTML type="url" validation. In the example I also provide different ways of specifying the URL schema and the issue appears to be present on all of them unless a custom error message is specified, in which case that will be displayed instead of Invalid input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    adapterRelated to validation adaptersbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions