{"record":{"id":"9f89eac55ec2d9b6","repo":"withastro/astro","slug":"unknowncontentcollectionerror-9f89ea","errorCode":"UnknownContentCollectionError","errorMessage":"Unexpected error reading entry ${JSON.stringify(fileId)}.","messagePattern":"Unexpected error reading entry (.+?)\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/vite-plugin-content-imports.ts","lineNumber":348,"sourceCode":"\t};\n\n\treturn dataEntryModule;\n}\n\n// Shared logic for `getContentEntryModule` and `getDataEntryModule`\n// Extracting to a helper was easier that conditionals and generics :)\nasync function getEntryModuleBaseInfo<TEntryType extends ContentEntryType | DataEntryType>({\n\tfileId,\n\tentryConfigByExt,\n\tcontentDir,\n\tfs,\n}: GetEntryModuleParams<TEntryType>) {\n\tconst contentConfig = await getContentConfigFromGlobal();\n\tlet rawContents;\n\ttry {\n\t\trawContents = await fs.promises.readFile(fileId, 'utf-8');\n\t} catch (e) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.UnknownContentCollectionError,\n\t\t\tmessage: `Unexpected error reading entry ${JSON.stringify(fileId)}.`,\n\t\t\tstack: e instanceof Error ? e.stack : undefined,\n\t\t});\n\t}\n\tconst fileExt = extname(fileId);\n\tconst entryConfig = entryConfigByExt.get(fileExt);\n\n\tif (!entryConfig) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.UnknownContentCollectionError,\n\t\t\tmessage: `No parser found for data entry ${JSON.stringify(\n\t\t\t\tfileId,\n\t\t\t)}. Did you apply an integration for this file type?`,\n\t\t});\n\t}\n\tconst entry = pathToFileURL(fileId);\n\tconst collection = getEntryCollectionName({ entry, contentDir });","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/content/vite-plugin-content-imports.ts#L330-L366","documentation":"vite-plugin-content-imports generates a module per entry when astro:content imports are requested in dev or build. Before emitting the module it reads the raw entry file; a read failure is wrapped as UnknownContentCollectionError with the underlying stack attached.","triggerScenarios":"The dev server holds a module for an entry that was just deleted or moved while an open page still imports it; file permissions or locking (antivirus on Windows); partial writes racing the watcher.","commonSituations":"Renaming/removing content entries while astro dev runs; editor atomic saves; monorepo watchers firing on half-written files; paths with characters the filesystem rejects.","solutions":["Restore the file or stop importing it, then reload — the dev server regenerates entry modules on demand.","Restart the dev server to clear the stale module graph.","Verify the path printed in the error exists and is readable.","If it recurs on every save, exclude src/content from antivirus scanning or tune watcher debounce."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Guard code that imports entries by id: confirm the file exists first\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nfunction assertEntryFile(collectionDir, id) {\n  const p = join(collectionDir, id);\n  if (!existsSync(p)) throw new Error(`entry file gone: ${p}`);\n}","typeGuard":null,"tryCatchPattern":"// In dev, a reload usually regenerates the module after file churn\ntry {\n  await import('astro:content');\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unexpected error reading entry')) {\n    // restart/reload dev server, then retry the import\n    throw new Error('entry file unreadable — restore it and reload the dev server', { cause: e });\n  }\n  throw e;\n}","preventionTips":["Rename or delete content entries only after closing pages that import them, or expect a transient error until reload.","Restart astro dev after bulk content moves.","Keep antivirus/watcher interference away from src/content on Windows."],"tags":["content-collections","dev-server","filesystem","vite"],"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"}