{"record":{"id":"66f69fba845a52a1","repo":"withastro/astro","slug":"generatecontenttypeserror","errorCode":"GenerateContentTypesError","errorMessage":"`astro sync` command failed to generate content collection types: ${errorMessage}.","messagePattern":"`astro sync` command failed to generate content collection types: (.+?)\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/sync/index.ts","lineNumber":352,"sourceCode":"\t\t\tconst contentPaths = getContentPaths(\n\t\t\t\tsettings.config,\n\t\t\t\tfs,\n\t\t\t\tsettings.config.legacy?.collectionsBackwardsCompat,\n\t\t\t);\n\t\t\tif (contentPaths.config.exists) {\n\t\t\t\tconst matches = /\\/(src\\/.+)/.exec(contentPaths.config.url.href);\n\t\t\t\tif (matches) {\n\t\t\t\t\tconfigFile = matches[1];\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\tconst hint = AstroUserError.is(e)\n\t\t\t? e.hint\n\t\t\t: AstroErrorData.GenerateContentTypesError.hint(configFile);\n\t\tthrow new AstroError(\n\t\t\t{\n\t\t\t\t...AstroErrorData.GenerateContentTypesError,\n\t\t\t\thint,\n\t\t\t\tmessage: AstroErrorData.GenerateContentTypesError.message(safeError.message),\n\t\t\t\tlocation: safeError.loc,\n\t\t\t},\n\t\t\t{ cause: e },\n\t\t);\n\t}\n}\n","sourceCodeStart":334,"sourceCodeEnd":363,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/sync/index.ts#L334-L363","documentation":"`astro sync` generates TypeScript types for content collections; it wraps any failure as AstroError code GenerateContentTypesError, attaching the original error as cause and a hint pointing at your content config file. The message embeds safeError.message and uses safeError.loc as location.","triggerScenarios":"A syntax or type error in src/content.config.ts (or src/content/config.ts); a bad collection schema (zod); an import that fails to resolve inside the config; an exception thrown while executing the config module.","commonSituations":"Editing the content config; upgrading the Content Layer API / collections API between versions; a typo in a collection name or schema field; a renamed import.","solutions":["Open the inner error (cause) and safeError.loc to find the exact failing line in the content config.","Fix the syntax/type/schema error in the content config file.","Re-run `astro sync` to confirm types generate cleanly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"async function runSync() {\n  try {\n    // import the content config to surface errors before astro sync runs\n    await import('./src/content.config.ts');\n  } catch (e) {\n    throw new Error('Content config error before sync: ' + e.message);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await sync();\n} catch (e) {\n  if (e.name === 'GenerateContentTypesError' && e.cause) {\n    console.error('Underlying failure:', e.cause);\n    // fix the content/config error, then re-run `astro sync`\n  } else throw e;\n}","preventionTips":["Keep src/content.config.ts syntactically valid and type-checked.","Run `astro sync` in CI to catch content config regressions.","Inspect the wrapped error's cause and location for the true source."],"tags":["content-collections","sync","build","typescript"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}