{"record":{"id":"c520bf66bf844b77","repo":"withastro/astro","slug":"rootrelativepath-contains-invalid-content","errorCode":null,"errorMessage":"**${rootRelativePath}** contains invalid content:\n${validationErrors}","messagePattern":"\\*\\*(.+?)\\*\\* contains invalid content:\n(.+?)","errorType":"validation","errorClass":"MarkdocError","httpStatus":null,"severity":"error","filePath":"packages/integrations/markdoc/src/content-entry-type.ts","lineNumber":260,"sourceCode":"\tastroConfig: AstroConfig;\n\tfilePath: string;\n}) {\n\tconst validationErrors = Markdoc.validate(ast, markdocConfig).filter((e) => {\n\t\treturn (\n\t\t\t(e.error.level === 'error' || e.error.level === 'critical') &&\n\t\t\t// Ignore `variable-undefined` errors.\n\t\t\t// Variables can be configured at runtime,\n\t\t\t// so we cannot validate them at build time.\n\t\t\te.error.id !== 'variable-undefined' &&\n\t\t\t// Ignore missing partial errors.\n\t\t\t// We will resolve these in `resolvePartials`.\n\t\t\t!(e.error.id === 'attribute-value-invalid' && /^Partial .+ not found/.test(e.error.message))\n\t\t);\n\t});\n\n\tif (validationErrors.length) {\n\t\tconst rootRelativePath = path.relative(fileURLToPath(astroConfig.root), filePath);\n\t\tthrow new MarkdocError({\n\t\t\tmessage: [\n\t\t\t\t`**${String(rootRelativePath)}** contains invalid content:`,\n\t\t\t\t...validationErrors.map((e) => `- ${e.error.message}`),\n\t\t\t].join('\\n'),\n\t\t\tlocation: {\n\t\t\t\t// Error overlay does not support multi-line or ranges.\n\t\t\t\t// Just point to the first line.\n\t\t\t\tline: validationErrors[0].lines[0],\n\t\t\t\tfile: viteId,\n\t\t\t},\n\t\t});\n\t}\n}\n\nfunction getUsedTags(markdocAst: Node) {\n\tconst tags = new Set<string>();\n\tconst validationErrors = Markdoc.validate(markdocAst);\n\t// Hack: run the validator with an empty config and look for 'tag-undefined'.","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/integrations/markdoc/src/content-entry-type.ts#L242-L278","documentation":"After Markdoc validates a content entry, the integration collects non-ignored validation errors (it skips `variable-undefined` and missing-partial `attribute-value-invalid` errors). If any remain, it throws a `MarkdocError` listing all of them, anchored to the first error's line and the Vite id so the overlay can display it.","triggerScenarios":"Authoring `.mdoc` content that fails Markdoc validation: invalid tag usage, unknown attributes, type mismatches (e.g. a Number attribute given a string), custom schema violations. Any validation error except `variable-undefined` and the `Partial ... not found` attribute-value-invalid case.","commonSituations":"Using a custom Markdoc tag/attribute incorrectly. Forgetting required attributes on a custom node. Markdoc config schema change not reflected in content. Typo in a tag name.","solutions":["Read the listed error messages; each line corresponds to one Markdoc validation error with its line number.","Open the file at the reported line and fix the offending tag/attribute usage.","If a reported attribute is intentional, adjust your Markdoc schema (`markdocConfig.tags`/`nodes`) to allow it.","Re-run the build to confirm no further validation errors."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Markdoc.validate(ast, markdocConfig);\n} catch (e) {\n  // surface per-error messages to the author\n  throw e;\n}","preventionTips":["Run `Markdoc.validate` during authoring/CI to catch schema violations early.","Keep `markdocConfig.tags`/`nodes` in sync with content usage.","Treat the first reported line as the anchor and fix downward."],"tags":["markdoc","validation","content-collections","build"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}