{"record":{"id":"31652b77273f8e03","repo":"withastro/astro","slug":"a-content-collection-is-defined-with-legacy-featur","errorCode":null,"errorMessage":"A content collection is defined with legacy features (e.g. missing a `loader` or has a `type`). Check your collection definitions in ${importerFilename} to ensure that all collections are defined using the current properties.","messagePattern":"A content collection is defined with legacy features \\(e\\.g\\. missing a `loader` or has a `type`\\)\\. Check your collection definitions in (.+?) to ensure that all collections are defined using the current properties\\.","errorType":"exception","errorClass":"AstroUserError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/config.ts","lineNumber":194,"sourceCode":"export function defineCollection<\n\tS extends BaseSchema,\n\tTLoader extends LoaderConstraint<{ id: string }> = LoaderConstraint<{ id: string }>,\n>(config: CollectionConfig<S, TLoader>): CollectionConfig<S, TLoader> {\n\tconst importerFilename = getImporterFilename();\n\n\tif (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'Collections in a live config file must use `defineLiveCollection`.',\n\t\t\t\timporterFilename,\n\t\t\t),\n\t\t});\n\t}\n\n\tif ('loader' in config) {\n\t\tif (config.type && config.type !== CONTENT_LAYER_TYPE) {\n\t\t\tthrow new AstroUserError(\n\t\t\t\t`A content collection is defined with legacy features (e.g. missing a \\`loader\\` or has a \\`type\\`). Check your collection definitions in ${importerFilename ?? 'your content config file'} to ensure that all collections are defined using the current properties.`,\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\ttypeof config.loader === 'object' &&\n\t\t\ttypeof config.loader.load !== 'function' &&\n\t\t\t('loadEntry' in config.loader || 'loadCollection' in config.loader)\n\t\t) {\n\t\t\tthrow new AstroUserError(\n\t\t\t\t`Live content collections must be defined in \"src/live.config.ts\" file. Check the loaders used in \"${importerFilename ?? 'your content config file'}\" to ensure you are not using a live loader to define a build-time content collection.`,\n\t\t\t);\n\t\t}\n\t\tconfig.type = CONTENT_LAYER_TYPE;\n\t}\n\tif (!config.type) config.type = 'content';\n\treturn config;\n}\n","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/content/config.ts#L176-L212","documentation":"`defineCollection` accepts a `loader` (content-layer style), but if the config also carries a legacy `type` field that is not the content-layer type, it is treated as a legacy (pre-content-layer) collection shape and rejected. Legacy collections used `type: 'content' | 'data'` and the implicit filesystem loader; the current API requires an explicit loader and no `type`.","triggerScenarios":"Calling `defineCollection({ type: 'content', loader })` or `defineCollection({ type: 'data' })` in `src/content/config.ts`.","commonSituations":"Upgrading from an older Astro where `type: 'content'` was standard; copy-pasting legacy examples; an integration scaffold emitting the old shape.","solutions":["Remove the `type` field from the collection config — it will default to `content` automatically.","Ensure you pass a `loader` (e.g. `glob()`, `file()`) for content-layer collections.","Run `astro sync` after editing to confirm the config is accepted."],"exampleFix":"// before\nconst posts = defineCollection({ type: 'content', schema });\n// after\nimport { glob } from 'astro/loaders';\nconst posts = defineCollection({ loader: glob('src/content/posts/*.md'), schema });","handlingStrategy":"validation","validationCode":"if ('loader' in config && config.type && config.type !== CONTENT_LAYER_TYPE) {\n  throw new Error('Remove the legacy type field; provide a loader instead');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drop `type` from `defineCollection` configs.","Always pass an explicit `loader` for content-layer collections.","Re-run `astro sync` after migrating legacy collection shapes."],"tags":["content-collections","legacy","config","migration"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}