chroma-core/chroma · error · ChromaValueError
Expected 'ids' to be a non-empty list
Error message
Expected 'ids' to be a non-empty list
What it means
ChromaValueError thrown by validateIDs (utils.ts:195) when ids is an array with zero elements. add/update require at least one id, and get/delete with an empty ids list is likewise rejected client-side rather than silently doing nothing.
Source
Thrown at clients/new-js/packages/chromadb/src/utils.ts:196
);
}
});
};
/**
* Validates an array of IDs for type correctness and uniqueness.
* @param ids - Array of ID strings to validate
* @throws ChromaValueError if IDs are not strings, empty, or contain duplicates
*/
export const validateIDs = (ids: string[]) => {
if (!Array.isArray(ids)) {
throw new ChromaValueError(
`Expected 'ids' to be an array, but got ${typeof ids}`,
);
}
if (ids.length === 0) {
throw new ChromaValueError("Expected 'ids' to be a non-empty list");
}
const nonStrings = ids
.map((id, i) => [id, i] as [any, number])
.filter(([id, _]) => typeof id !== "string")
.map(([_, i]) => i);
if (nonStrings.length > 0) {
throw new ChromaValueError(
`Found non-string IDs at ${nonStrings.join(", ")}`,
);
}
const seen = new Set();
const duplicates = ids.filter((id) => {
if (seen.has(id)) {
return id;
}View on GitHub (pinned to aecdd12c8a)
Solutions
- Skip the operation when ids is empty: if (!ids.length) return 0
- For 'delete everything', call collection.delete({}) or use a where filter rather than an empty ids array
- Guard chunked ingestion loops against zero-length chunks
Example fix
// before
await collection.delete({ ids: matchedIds }); // matchedIds === []
// after
if (matchedIds.length === 0) return { deleted: 0 };
await collection.delete({ ids: matchedIds }); Defensive patterns
Strategy: validation
Validate before calling
if (Array.isArray(ids) && ids.length === 0) return { deleted: 0 }; Type guard
const hasIds = (v) => Array.isArray(v) && v.length > 0;
Try / catch
try { await collection.delete({ ids }); } catch (e) { if (e instanceof ChromaValueError && /'ids' to be a non-empty list/.test(e.message)) return 0; else throw e; } Prevention
- Skip delete/get when the resolved id list is empty
- Use collection.delete({}) or where filters for delete-all semantics
- Guard chunked loops against empty chunks
When it happens
Trigger: collection.add({ ids: [], documents: [] }); collection.delete({ ids: [] }); a deletion routine computing affected ids and finding none.
Common situations: Delete-by-filter flows that resolve zero matching ids; empty batches from upstream; using [] intending 'match all' (use no ids field or a where filter instead).
Related errors
- Non-empty lists are required for ${zeroLength.join(", ")}
- Expected embeddings to be an array with at least one item
- Expected each embedding to be a non-empty array of numbers,
- Expected '${fieldName}' to be a non-empty list
- Expected 'ids' to be an array, but got ${typeof ids}
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/4c317a91a90f9d96.
Report an issue: GitHub.