{"record":{"id":"438da1c13d4a8eee","repo":"withastro/astro","slug":"the-glob-loader-cannot-be-used-for-files-in-co","errorCode":null,"errorMessage":"The glob() loader cannot be used for files in ${colors.bold('src/content')} when legacy mode is enabled.","messagePattern":"The glob\\(\\) loader cannot be used for files in (.+?) when legacy mode is enabled\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/content/loaders/glob.ts","lineNumber":339,"sourceCode":"\t\t\t\tfiles.map((entry) => {\n\t\t\t\t\tif (isConfigFile(entry)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\treturn limit(async () => {\n\t\t\t\t\t\tconst entryType = configForFile(entry);\n\t\t\t\t\t\tawait syncData(entry, baseDir, entryType);\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\tconst skipCount = skippedFiles.length;\n\n\t\t\tif (skipCount > 0) {\n\t\t\t\tconst patternList = Array.isArray(globOptions.pattern)\n\t\t\t\t\t? globOptions.pattern.join(', ')\n\t\t\t\t\t: globOptions.pattern;\n\n\t\t\t\tlogger.warn(\n\t\t\t\t\t`The glob() loader cannot be used for files in ${colors.bold('src/content')} when legacy mode is enabled.`,\n\t\t\t\t);\n\t\t\t\tif (skipCount > 10) {\n\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t`Skipped ${colors.green(skippedFiles.length)} files that matched ${colors.green(patternList)}.`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.warn(`Skipped the following files that matched ${colors.green(patternList)}:`);\n\t\t\t\t\tskippedFiles.forEach((file) => logger.warn(`• ${colors.green(file)}`));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove entries that were not found this time\n\t\t\tuntouchedEntries.forEach((id) => store.delete(id));\n\n\t\t\tif (!watcher) {\n\t\t\t\treturn;\n\t\t\t}","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/content/loaders/glob.ts#L321-L357","documentation":"When legacy content collections are enabled (legacy.collectionsBackwardsCompat in astro.config.mjs) and a glob() loader matched files inside src/content, those files are skipped because the legacy pipeline owns src/content. If any files were skipped, the loader emits this warning explaining the glob() loader cannot be used there in legacy mode, followed by a count or list of the skipped files.","triggerScenarios":"Enabling legacy.collectionsBackwardsCompat while a content-layer collection's glob base (defaulted to the collection directory under src/content) matches files inside src/content.","commonSituations":"Projects mid-migration from Astro 4/5 legacy collections to the Content Layer that keep some collections under src/content; copy-pasting content-layer config into a legacy-mode project.","solutions":["Migrate the collection off legacy mode (remove legacy.collectionsBackwardsCompat) so the glob loader can own src/content files","Move the collection's source out of src/content (e.g. src/data/blog) and set an explicit base so the glob loader can read it while legacy mode stays on","Delete the matched files from src/content if they are leftovers from an aborted migration"],"exampleFix":"// before: astro.config.mjs keeps legacy on, collection lives in src/content\nexport default defineConfig({ legacy: { collectionsBackwardsCompat: true } });\n\n// after: move files to src/data/blog and point the loader there\nconst blog = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/data/blog' }) });","handlingStrategy":"validation","validationCode":"// Guard config: refuse glob loaders targeting src/content under legacy mode\nfunction assertNoLegacyOverlap(config: { legacy?: { collectionsBackwardsCompat?: boolean } }, base: string) {\n  if (config.legacy?.collectionsBackwardsCompat && base.includes('/src/content')) {\n    throw new Error('glob() loader cannot read src/content while legacy.collectionsBackwardsCompat is enabled');\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Complete the migration and remove legacy.collectionsBackwardsCompat as soon as possible","Keep content-layer sources outside src/content (e.g. src/data/) while legacy mode is on","Add a config lint that flags glob bases resolving into src/content when legacy mode is enabled"],"tags":["astro","content-collections","glob-loader","legacy","migration"],"backgroundTag":"legacy-mode-conflict","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}