{"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":837,"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":819,"sourceCodeEnd":855,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/content/utils.ts#L819-L855","documentation":"During content sync, Astro reads each discovered entry file from disk. If fs.readFile rejects — the file vanished between discovery and read, permissions block it, or a symlink is broken — the failure is rethrown as UnknownContentCollectionError with the original error attached as cause.","triggerScenarios":"An entry file deleted or renamed while a build or dev-server watch sync is in progress; unreadable file permissions; broken symlinks inside src/content; content stored on flaky network mounts.","commonSituations":"Switching git branches while astro dev watches content; editors doing atomic save-replace exactly as sync runs; Docker volume permission mismatches; CI caches restoring stale trees.","solutions":["Re-run the build or wait for the next dev-server sync — transient races during file churn usually clear.","Check that the file exists and is readable; look for broken symlinks in src/content.","Fix permissions or mounts if the error persists, then restart astro dev.","If reproducible, inspect error.cause for the underlying errno (ENOENT vs EACCES) to narrow it down."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before batch operations, verify every entry file still exists\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nconst missing = expectedEntryPaths.filter((p) => !existsSync(join('src/content', p)));\nif (missing.length) throw new Error(`entries vanished: ${missing.join(', ')}`);","typeGuard":null,"tryCatchPattern":"// Transient during watch; retry once before surfacing\ntry {\n  await syncContent();\n} catch (e) {\n  if (e instanceof Error && e.cause && e.cause.code === 'ENOENT') {\n    await new Promise((r) => setTimeout(r, 500));\n    await syncContent(); // file churn usually settles\n  } else throw e;\n}","preventionTips":["Avoid switching branches or bulk-moving content while astro dev or a build is running.","Commit and pull content changes with the dev server stopped.","Check file permissions and symlinks in src/content when the error persists.","Inspect error.cause for the real errno before assuming data corruption."],"tags":["content-collections","filesystem","build","race-condition"],"backgroundTag":"file-read-failed","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}