{"record":{"id":"24b9feb43bfea64a","repo":"withastro/astro","slug":"unknowncontentcollectionerror-24b9fe","errorCode":"UnknownContentCollectionError","errorMessage":"Unknown content collection error.","messagePattern":"Unknown content collection error\\.","errorType":"error_code","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/utils.ts","lineNumber":829,"sourceCode":"\tcollection,\n\tgeneratedSlug,\n\tcontentEntryType,\n\tfileUrl,\n\tfs,\n}: {\n\tfs: typeof fsMod;\n\tid: string;\n\tcollection: string;\n\tgeneratedSlug: string;\n\tfileUrl: URL;\n\tcontentEntryType: Pick<ContentEntryType, 'getEntryInfo'>;\n}) {\n\tlet contents: string;\n\ttry {\n\t\tcontents = await fs.promises.readFile(fileUrl, 'utf-8');\n\t} catch (e) {\n\t\t// File contents should exist. Raise unexpected error as \"unknown\" if not.\n\t\tthrow new AstroError(AstroErrorData.UnknownContentCollectionError, { cause: e });\n\t}\n\tconst { slug: frontmatterSlug } = await contentEntryType.getEntryInfo({\n\t\tfileUrl,\n\t\tcontents,\n\t});\n\treturn parseEntrySlug({ generatedSlug, frontmatterSlug, id, collection });\n}\n\nfunction getExtGlob(exts: string[]) {\n\treturn exts.length === 1\n\t\t? // Wrapping {...} breaks when there is only one extension\n\t\t\texts[0]\n\t\t: `{${exts.join(',')}}`;\n}\n\nfunction globWithUnderscoresIgnored(relContentDir: string, exts: string[]): string[] {\n\tconst extGlob = getExtGlob(exts);\n\tconst contentDir = relContentDir.length > 0 ? appendForwardSlash(relContentDir) : relContentDir;","sourceCodeStart":811,"sourceCodeEnd":847,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/content/utils.ts#L811-L847","documentation":"A catch-all error thrown when `fs.promises.readFile` fails while reading a content entry file inside `getContentEntryType` processing. The original filesystem error is attached as `cause`. This is an unexpected-error wrapper: the file was expected to exist and be readable, so a failure here indicates a race condition, permission issue, or the file was deleted between discovery and read.","triggerScenarios":"`getEntryInfo` is called for a content entry whose file URL was previously resolved. The `readFile` call throws (ENOENT, EACCES, EISDIR, etc.), and the error is wrapped with `UnknownContentCollectionError` as the top-level AstroError and the filesystem error as `cause`.","commonSituations":"A file is deleted or moved while `astro dev` is running and HMR hasn't caught up. Filesystem permissions deny read access to the content directory. A symlink loop or broken symlink points to a non-existent target. An editor's safe-save temporarily removes the file.","solutions":["Check that the file at the path in the error message still exists and is readable.","Restart `astro dev` to re-scan the content directory.","Fix filesystem permissions on the content directory (`chmod -R+r src/content`).","Remove or fix broken symlinks in the content directory.","If using a remote/cloud-synced filesystem, ensure sync is complete before building."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { existsSync, accessSync, constants } from 'fs';\nfunction ensureReadable(filePath: string) {\n  if (!existsSync(filePath)) throw new Error(`Missing: ${filePath}`);\n  accessSync(filePath, constants.R_OK);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const data = await getEntry('blog', 'post');\n} catch (e) {\n  if (e instanceof Error && /Unknown content collection error/.test(e.message)) {\n    console.error('Filesystem issue — check file exists:', e.cause);\n  }\n  throw e;\n}","preventionTips":["Avoid editing content files while astro dev is running; use a save hook instead.","Ensure content directories have read permissions in CI.","Run a file-existence check in pre-build scripts for critical entries."],"tags":["content-collections","filesystem","race-condition"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}