{"record":{"id":"90d14269d1e1cf03","repo":"withastro/astro","slug":"string-relativepartialpath-contains-invali","errorCode":null,"errorMessage":"**${String(relativePartialPath)}** contains invalid content:\nCould not read partial file `${file}`. Does the file exist?","messagePattern":"\\*\\*(.+?)\\*\\* contains invalid content:\nCould not read partial file `(.+?)`\\. Does the file exist\\?","errorType":"exception","errorClass":"MarkdocError","httpStatus":null,"severity":"error","filePath":"packages/integrations/markdoc/src/content-entry-type.ts","lineNumber":202,"sourceCode":"\n\t\t\tlet partialPath: string;\n\t\t\tlet partialContents: string;\n\t\t\ttry {\n\t\t\t\tconst resolved = await pluginContext.resolve(file, fileURLToPath(fileUrl));\n\t\t\t\tlet partialId = resolved?.id;\n\t\t\t\tif (!partialId) {\n\t\t\t\t\tconst attemptResolveAsRelative = await pluginContext.resolve(\n\t\t\t\t\t\t'./' + file,\n\t\t\t\t\t\tfileURLToPath(fileUrl),\n\t\t\t\t\t);\n\t\t\t\t\tif (!attemptResolveAsRelative?.id) throw new Error();\n\t\t\t\t\tpartialId = attemptResolveAsRelative.id;\n\t\t\t\t}\n\n\t\t\t\tpartialPath = fileURLToPath(new URL(prependForwardSlash(partialId), 'file://'));\n\t\t\t\tpartialContents = await fs.promises.readFile(partialPath, 'utf-8');\n\t\t\t} catch {\n\t\t\t\tthrow new MarkdocError({\n\t\t\t\t\tmessage: [\n\t\t\t\t\t\t`**${String(relativePartialPath)}** contains invalid content:`,\n\t\t\t\t\t\t`Could not read partial file \\`${file}\\`. Does the file exist?`,\n\t\t\t\t\t].join('\\n'),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (pluginContext.meta.watchMode) pluginContext.addWatchFile(partialPath);\n\t\t\tlet partialTokens = tokenizer.tokenize(partialContents);\n\t\t\tif (allowHTML) {\n\t\t\t\tpartialTokens = htmlTokenTransform(tokenizer, partialTokens);\n\t\t\t}\n\t\t\tconst partialAst = Markdoc.parse(partialTokens);\n\t\t\traisePartialValidationErrors(partialAst, partialPath);\n\t\t\tawait resolvePartials({\n\t\t\t\tast: partialAst,\n\t\t\t\troot,\n\t\t\t\tfileUrl: pathToFileURL(partialPath),\n\t\t\t\ttokenizer,","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/integrations/markdoc/src/content-entry-type.ts#L184-L220","documentation":"When a `{% partial file=\"x\" %}` tag does not match an entry in the Markdoc config's `partials` map, the integration tries to resolve `x` as a module from the containing file and read it from disk. If resolution or fs.readFile fails (missing file, wrong path, unreadable), it throws this MarkdocError naming the containing document and the requested partial. The generic `throw new Error()` inside the try block funnels every failure mode into this one message.","triggerScenarios":"Referencing `{% partial file=\"headers/foo\" %}` where src/.../headers/foo.md(md) does not exist; a path that neither resolves bare nor as `./path` relative to the .mdoc file; the file exists but cannot be read (permissions).","commonSituations":"Renaming or moving partial files without updating references; wrong relative depth (`../` vs `./`); missing file extension that the resolver expects; partials directory not where the author assumes.","solutions":["Verify the partial file exists at the path you reference, relative to the content file that includes it.","Use the exact import specifier style that resolves: `./`-prefixed relative paths are the reliable form.","Alternatively register partials explicitly via `partials` in the Markdoc config passed to the integration.","Check file permissions if it exists but still fails."],"exampleFix":"{% partial file=\"missing/header\" /%}\n\n{% partial file=\"./src/content/partials/header\" /%}","handlingStrategy":"validation","validationCode":"// Pre-build check: every referenced partial file resolves relative to its content file\nimport { Markdoc } from '@markdoc/markdoc';\nimport { globSync } from 'glob';\nimport fs from 'node:fs';\nimport path from 'node:path';\nfor (const f of globSync('src/**/*.mdoc')) {\n  const ast = Markdoc.parse(fs.readFileSync(f, 'utf8'));\n  for (const node of ast.walk()) {\n    if (node.type === 'tag' && node.tag === 'partial' && typeof node.attributes.file === 'string') {\n      const p = path.resolve(path.dirname(f), node.attributes.file.replace(/^\\//, ''));\n      if (!fs.existsSync(p)) throw new Error(`${f}: partial not found at ${p}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt one canonical partials directory and reference it with `./`-relative paths.","Add an existence check for partial references to CI.","Prefer registering partials in the markdoc config map when paths are dynamic."],"tags":["markdoc","partials","file-resolution","content"],"backgroundTag":"partial-file-not-found","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}