withastro/astro · warning
No items found in ${fileName}
Error message
No items found in ${fileName} What it means
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').
Source
Thrown at packages/astro/src/content/loaders/file.ts:75
filePath: string,
{ logger, parseData, store, config, collection }: LoaderContext,
) {
let data: Array<Record<string, unknown>> | Record<string, Record<string, unknown>>;
try {
const contents = await fs.readFile(filePath, 'utf-8');
data = await parse!(contents);
} catch (error: any) {
logger.error(`Error reading data from ${fileName}`);
logger.debug(error.message);
return;
}
const normalizedFilePath = posixRelative(fileURLToPath(config.root), filePath);
if (Array.isArray(data)) {
if (data.length === 0) {
logger.warn(`No items found in ${fileName}`);
}
logger.debug(`Found ${data.length} item array in ${fileName}`);
store.clear();
const idList = new Set();
for (const rawItem of data) {
const id = (rawItem.id ?? rawItem.slug)?.toString();
if (!id) {
logger.error(`Item in ${fileName} is missing an id or slug field.`);
continue;
}
if (idList.has(id)) {
const message = DuplicateContentEntrySlugError.message(
collection,
id,
fileName,
fileName,
);
if (config.prerenderConflictBehavior === 'error') {View on GitHub (pinned to 52e6c34790)
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
Example fix
// before: src/data/authors.json
[]
// after
[
{ "id": "alice", "name": "Alice" }
] Defensive patterns
Strategy: validation
Validate before calling
// Lint content data files for empty arrays before build
import { readFileSync } from 'node:fs';
function dataFileHasItems(path: string): boolean {
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
return Array.isArray(parsed)
? parsed.length > 0
: Object.keys(parsed).some((k) => k !== '$schema');
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Placeholder data files committed before content exists; scaffolding templates that generate empty arrays; accidental truncation of a data file during merge or sync.
Related errors
- **${collection}** contains multiple entries with the same sl
- [content] Could not read the chunked data store at ${fileURL
- FileGlobNotSupported
- FileParserNotFound
- DuplicateContentEntrySlugError
AI-assisted analysis of withastro/astro@52e6c34790 (2026-08-18).
Data as JSON: /api/errors/6e30a51019c54936.
Report an issue: GitHub.