{"record":{"id":"6e30a51019c54936","repo":"withastro/astro","slug":"no-items-found-in-filename","errorCode":null,"errorMessage":"No items found in ${fileName}","messagePattern":"No items found in (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/content/loaders/file.ts","lineNumber":75,"sourceCode":"\t\tfilePath: string,\n\t\t{ logger, parseData, store, config, collection }: LoaderContext,\n\t) {\n\t\tlet data: Array<Record<string, unknown>> | Record<string, Record<string, unknown>>;\n\n\t\ttry {\n\t\t\tconst contents = await fs.readFile(filePath, 'utf-8');\n\t\t\tdata = await parse!(contents);\n\t\t} catch (error: any) {\n\t\t\tlogger.error(`Error reading data from ${fileName}`);\n\t\t\tlogger.debug(error.message);\n\t\t\treturn;\n\t\t}\n\n\t\tconst normalizedFilePath = posixRelative(fileURLToPath(config.root), filePath);\n\n\t\tif (Array.isArray(data)) {\n\t\t\tif (data.length === 0) {\n\t\t\t\tlogger.warn(`No items found in ${fileName}`);\n\t\t\t}\n\t\t\tlogger.debug(`Found ${data.length} item array in ${fileName}`);\n\t\t\tstore.clear();\n\t\t\tconst idList = new Set();\n\t\t\tfor (const rawItem of data) {\n\t\t\t\tconst id = (rawItem.id ?? rawItem.slug)?.toString();\n\t\t\t\tif (!id) {\n\t\t\t\t\tlogger.error(`Item in ${fileName} is missing an id or slug field.`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (idList.has(id)) {\n\t\t\t\t\tconst message = DuplicateContentEntrySlugError.message(\n\t\t\t\t\t\tcollection,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tfileName,\n\t\t\t\t\t\tfileName,\n\t\t\t\t\t);\n\t\t\t\t\tif (config.prerenderConflictBehavior === 'error') {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/content/loaders/file.ts#L57-L93","documentation":"The file() loader parsed your data file into a top-level array with zero entries, so the collection ends up empty. Astro logs this warning (plus a debug line with the item count) but does not fail: the store is cleared and no entries are stored. Parse failures are a different path ('Error reading data from').","triggerScenarios":"A JSON/YAML/TOML file referenced by file() whose parsed top-level value is an empty array ([] in JSON, or an empty YAML sequence), so data.length === 0 after successful parsing.","commonSituations":"Placeholder data files committed before content exists; scaffolding templates that generate empty arrays; accidental truncation of a data file during merge or sync.","solutions":["Add at least one entry to the data file","If the collection is intentionally empty for now, ignore the warning","Remove the collection (or its file() loader) from the content config if it is no longer needed"],"exampleFix":"// before: src/data/authors.json\n[]\n\n// after\n[\n  { \"id\": \"alice\", \"name\": \"Alice\" }\n]","handlingStrategy":"validation","validationCode":"// Lint content data files for empty arrays before build\nimport { readFileSync } from 'node:fs';\nfunction dataFileHasItems(path: string): boolean {\n  const parsed = JSON.parse(readFileSync(path, 'utf-8'));\n  return Array.isArray(parsed)\n    ? parsed.length > 0\n    : Object.keys(parsed).some((k) => k !== '$schema');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Seed new data files with at least one real entry instead of committing []","Treat this warning as a possible sign of a truncated file after merges or syncs","Add a pre-build lint that flags empty top-level arrays in collection data files"],"tags":["astro","content-collections","file-loader","empty-data"],"backgroundTag":"empty-content-collection","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}