{"record":{"id":"c83c60026b466a72","repo":"withastro/astro","slug":"livecontentconfigerror","errorCode":"LiveContentConfigError","errorMessage":"Live collections must be defined in a `src/live.config.ts` file. Check your collection definitions in ${importerFilename ?? 'your content config file'}.","messagePattern":"Live collections must be defined in a `src/live\\.config\\.ts` file\\. Check your collection definitions in (.+?)\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/config.ts","lineNumber":123,"sourceCode":"\tS extends BaseSchema | undefined = undefined,\n> = {\n\ttype?: 'live';\n\tschema?: S;\n\tloader: L;\n};\n\nexport type CollectionConfig<\n\tS extends BaseSchema,\n\tTLoader extends LoaderConstraint<{ id: string }> = LoaderConstraint<{ id: string }>,\n> = ContentCollectionConfig<S> | DataCollectionConfig<S> | ContentLayerConfig<S, TLoader>;\n\nexport function defineLiveCollection<\n\tL extends LiveLoader,\n\tS extends BaseSchema | undefined = undefined,\n>(config: LiveCollectionConfig<L, S>): LiveCollectionConfig<L, S> {\n\tconst importerFilename = getImporterFilename();\n\tif (importerFilename && !importerFilename.includes('live.config')) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.LiveContentConfigError,\n\t\t\tmessage: AstroErrorData.LiveContentConfigError.message(\n\t\t\t\t'Live collections must be defined in a `src/live.config.ts` file.',\n\t\t\t\timporterFilename ?? 'your content config file',\n\t\t\t),\n\t\t});\n\t}\n\t// Default to live content type if not specified\n\tconfig.type ??= LIVE_CONTENT_TYPE;\n\n\tif (config.type !== LIVE_CONTENT_TYPE) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.LiveContentConfigError,\n\t\t\tmessage: AstroErrorData.LiveContentConfigError.message(\n\t\t\t\t'Collections in a live config file must have a type of `live`.',\n\t\t\t\timporterFilename,\n\t\t\t),\n\t\t});","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/withastro/astro/blob/157c500c38faa7ecf1251adbaeefcd109470d75c/packages/astro/src/content/config.ts#L105-L141","documentation":"`defineLiveCollection` inspects the stack trace to find its importing file and refuses to run outside a `live.config` file. Live collections (request-time data with live loaders) are only valid when defined in `src/live.config.ts`; the config file location is part of the contract, so defining them anywhere else — including `src/content.config.ts` — is rejected with LiveContentConfigError.","triggerScenarios":"Calling `defineLiveCollection({...})` in `src/content.config.ts`, a shared `collections.ts` helper module, or any file whose name does not contain 'live.config'; re-exporting or wrapping defineLiveCollection from a utility module (the stack-walk still finds the ultimate importer).","commonSituations":"Migrating to live collections and leaving definitions in the old content config; teams putting all collection config in one shared file; helper modules for schemas that also define collections.","solutions":["Move every `defineLiveCollection` call into `src/live.config.ts`","Keep shared schemas/loaders in separate modules and import them from live.config.ts — only the define* calls must live in the config file itself","If the collection is actually build-time, use `defineCollection` in src/content.config.ts instead"],"exampleFix":"// before — src/content.config.ts\nimport { defineLiveCollection } from 'astro:content';\nexport const collections = { posts: defineLiveCollection({ loader }) };\n\n// after — src/live.config.ts\nexport const collections = { posts: defineLiveCollection({ loader }) };","handlingStrategy":"validation","validationCode":"// guard shared config modules: only allow defineLiveCollection from live.config.*\nconst file = import.meta.url;\nif (!/live\\.config\\.[cm]?[jt]s$/.test(file)) {\n  throw new Error('defineLiveCollection may only be called from src/live.config.ts');\n}\nexport const collections = { posts: defineLiveCollection({ loader }) };","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep exactly two config files: src/content.config.ts (build-time) and src/live.config.ts (live) — never define live collections elsewhere","Put shared schemas/loaders in plain modules and import them; only the define* calls must sit in the config file","During migration, move collections one at a time and run `astro build`/dev after each move"],"tags":["content-collections","live-content","configuration"],"backgroundTag":"invalid-config-file-location","analyzedSha":"157c500c38faa7ecf1251adbaeefcd109470d75c","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}