{"record":{"id":"6ee8f1b42bedc55f","repo":"withastro/astro","slug":"unknowncontentcollectionerror","errorCode":"UnknownContentCollectionError","errorMessage":"Collection \"${collection}\" is a live collection. Use getLiveCollection() instead of getCollection().","messagePattern":"Collection \"(.+?)\" is a live collection\\. Use getLiveCollection\\(\\) instead of getCollection\\(\\)\\.","errorType":"error_code","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/runtime.ts","lineNumber":105,"sourceCode":"\t\t\t\tcollection,\n\t\t\t\t`Unexpected error parsing entry ${entry.id} in collection ${collection}`,\n\t\t\t\terror as Error,\n\t\t\t),\n\t\t};\n\t}\n}\n\nexport function createGetCollection({\n\tliveCollections,\n}: {\n\tliveCollections: LiveCollectionConfigMap;\n}) {\n\treturn async function getCollection(\n\t\tcollection: string,\n\t\tfilter?: ((entry: any) => unknown) | Record<string, unknown>,\n\t) {\n\t\tif (collection in liveCollections) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.UnknownContentCollectionError,\n\t\t\t\tmessage: `Collection \"${collection}\" is a live collection. Use getLiveCollection() instead of getCollection().`,\n\t\t\t});\n\t\t}\n\n\t\tconst hasFilter = typeof filter === 'function';\n\t\tconst store = await globalDataStore.get();\n\t\tif (await store.hasCollection(collection)) {\n\t\t\t// @ts-expect-error\tvirtual module\n\t\t\tconst { default: imageAssetMap } = await import('astro:asset-imports');\n\n\t\t\tconst result = [];\n\t\t\tfor (const rawEntry of await store.values<DataEntry>(collection)) {\n\t\t\t\tconst data = resolveEntryData(rawEntry, imageAssetMap);\n\n\t\t\t\tlet entry = {\n\t\t\t\t\t...rawEntry,\n\t\t\t\t\tdata,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/content/runtime.ts#L87-L123","documentation":"Thrown when getCollection() is called with the name of a collection that was registered as a live collection. Live collections have a different data path (fetched on demand) and must be accessed via getLiveCollection(); the standard getCollection() refuses to silently return stale or empty results.","triggerScenarios":"Calling getCollection('news') where 'news' is defined with type:'live' in src/live.config.ts; mixing up the two access APIs after migrating a collection to live.","commonSituations":"Migrating a static collection to a live collection but forgetting to update call sites; copy-pasting getCollection() into a component that handles a live collection; renaming a collection and losing track of its type.","solutions":["Use getLiveCollection('name') instead of getCollection('name').","Double-check src/live.config.ts and src/content/config.ts to confirm which collections are live.","If you intended a static collection, move its definition out of live.config.ts into the standard content config."],"exampleFix":"// before\nconst posts = await getCollection('news');\n// after\nconst posts = await getLiveCollection('news');","handlingStrategy":"type-guard","validationCode":"// Maintain a typed registry so call sites can't mix static/live\nconst LIVE = new Set(['news','scores']);\nfunction isLive(name: string) { return LIVE.has(name); }\nif (isLive(name)) throw new Error(`use getLiveCollection for ${name}`);","typeGuard":"declare const brand: unique symbol; type LiveName = string & { [brand]: 'live' }; type StaticName = string & { [brand]: 'static' };","tryCatchPattern":null,"preventionTips":["Centralize collection access behind helpers that route to getCollection vs getLiveCollection.","Keep src/content/config.ts and src/live.config.ts disjoint.","Add a comment per collection indicating its type at the call site."],"tags":["content-collections","live-collections","runtime","api-mismatch"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}