Skip to content

Fix content collection validation errors showing raw JSON#15981

Open
moktamd wants to merge 2 commits intowithastro:mainfrom
moktamd:fix/zod-v4-validation-error-format
Open

Fix content collection validation errors showing raw JSON#15981
moktamd wants to merge 2 commits intowithastro:mainfrom
moktamd:fix/zod-v4-validation-error-format

Conversation

@moktamd
Copy link

@moktamd moktamd commented Mar 18, 2026

Fixes #15976

Since the Zod v3 → v4 migration (#14956), $ZodError.message returns a JSON-stringified array instead of a human-readable string. The three content error definitions in errors-data.ts used error.message directly, producing output like:

  **: [
  {
    "expected": "object",
    "code": "invalid_type",
    ...
  }
]

This iterates over error.issues instead, producing:

  **label**: Required

This matches the pattern already used in content/loaders/errors.ts and content/utils.ts.

Since the Zod v3 → v4 migration, $ZodError.message returns a
JSON-stringified array instead of a human-readable string. Format
validation errors by iterating over error.issues, matching the
pattern already used in content/loaders/errors.ts.
@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: ccdceca

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr labels Mar 18, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing moktamd:fix/zod-v4-validation-error-format (ccdceca) with main (2dca307)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (efcd607) during the generation of this report, so 2dca307 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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

Labels

docs pr pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content collection validation errors in v6 are no longer human-readable

1 participant