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".
[InvalidContentEntryFrontmatterError] blog -> first-post.md frontmatter does not match
collection schema.
pubDate: RequiredCommon 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
- Read the Zod path in the error to see which field and entry failed.
- Add the missing field or correct its type in the Markdown frontmatter.
- Re-run the build to validate the whole collection.
---
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.
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.