{"record":{"id":"3084d34d54af5955","repo":"withastro/astro","slug":"relativepartialpath-contains-invalid-conten","errorCode":null,"errorMessage":"**${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/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/integrations/markdoc/src/content-entry-type.ts#L184-L220","documentation":"During partial resolution the integration tries to resolve the `file` value via the Rolldown plugin context (`pluginContext.resolve`), falls back to `./` + file, and reads the resolved path with `fs.promises.readFile`. If resolution returns no id or reading throws, a `MarkdocError` is raised naming the partial and noting the file may not exist.","triggerScenarios":"Referencing `{% partial file=\"./missing.mdoc\" / %}` where the file does not exist on disk. Path that cannot be resolved by Rolldown/Vite from the importing `.mdoc`'s location. Symlink or permission issue during read. Partial path is absolute or non-relative and resolve fails both attempts.","commonSituations":"Typo in the partial path. Moved/deleted a partial without updating references. Importing a partial from a directory not covered by Vite's `fs.allow`. Case-sensitivity mismatch between macOS dev and Linux build.","solutions":["Verify the partial file exists at the path declared in `file=`.","Use a path that resolves relative to the `.mdoc` file importing it (prefix with `./` if needed).","Check filesystem case matches exactly on case-sensitive build environments.","Confirm the partial is inside the Astro project root or an allowed Vite dir."],"exampleFix":"{% partial file=\"./_nav.mdoc\" / %}","handlingStrategy":"validation","validationCode":"import { pathExists } from 'fs-extra';\nasync function partialExists(file: string, from: string) {\n  const resolved = path.resolve(path.dirname(from), file);\n  return await pathExists(resolved);\n}","typeGuard":"async function canReadPartial(file: string, baseDir: string): Promise<boolean> {\n  try {\n    await fs.promises.access(path.resolve(baseDir, file));\n    return true;\n  } catch { return false; }\n}","tryCatchPattern":"try {\n  await resolvePartial(file, fileUrl);\n} catch (e) {\n  console.error(`Could not read partial ${file} from ${fileUrl}`);\n  throw e;\n}","preventionTips":["Reference partials with explicit relative paths (`./name.mdoc`).","Run `astro check` / Markdoc validation locally before push.","Keep partials inside the project root."],"tags":["markdoc","partials","filesystem","build"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}