Skip to content
Latchkey

Astro content collection schema validation error in CI

Astro validates every content collection entry against the Zod schema in src/content/config.ts. When a frontmatter field is missing, mistyped, or invalid, the build fails with the exact field and reason.

What this error means

astro build fails with "[InvalidContentEntryFrontmatterError] ... frontmatter does not match collection schema" and a Zod path such as "pubDate: Required" or "draft: Expected boolean, received string".

astro
[InvalidContentEntryFrontmatterError] blog -> first-post.md frontmatter does not match
collection schema.
pubDate: Required

Common causes

A required frontmatter field is missing

The schema marks a field as required but an entry omits it, so Zod rejects the entry during the build.

A field has the wrong type

A value such as draft: "true" is a string where the schema expects a boolean, or a date string fails z.coerce.date().

How to fix it

Fix the offending frontmatter to match the schema

  1. Read the Zod path in the error to see which field and entry failed.
  2. Add the missing field or correct its type in the Markdown frontmatter.
  3. Re-run the build to validate the whole collection.
src/content/blog/first-post.md
---
title: First post
pubDate: 2026-06-30
draft: false
---

Relax or coerce the schema if intended

If the value is genuinely optional, make the field optional or coerce its type in the collection config.

src/content/config.ts
const blog = defineCollection({
  schema: z.object({
    title: z.string(),
    pubDate: z.coerce.date(),
    draft: z.boolean().default(false),
  }),
});

How to prevent it

  • Keep frontmatter fields aligned with the collection schema.
  • Use z.coerce.date() for dates written as strings.
  • Run the build locally so schema errors surface before CI.

Frequently asked questions

What causes "content collection schema error"?
The schema marks a field as required but an entry omits it, so Zod rejects the entry during the build.
How do I fix content collection schema error?
Fix the offending frontmatter to match the schema

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card