{"record":{"id":"4c317a91a90f9d96","repo":"chroma-core/chroma","slug":"expected-ids-to-be-a-non-empty-list","errorCode":null,"errorMessage":"Expected 'ids' to be a non-empty list","messagePattern":"Expected 'ids' to be a non-empty list","errorType":"validation","errorClass":"ChromaValueError","httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/chromadb/src/utils.ts","lineNumber":196,"sourceCode":"      );\n    }\n  });\n};\n\n/**\n * Validates an array of IDs for type correctness and uniqueness.\n * @param ids - Array of ID strings to validate\n * @throws ChromaValueError if IDs are not strings, empty, or contain duplicates\n */\nexport const validateIDs = (ids: string[]) => {\n  if (!Array.isArray(ids)) {\n    throw new ChromaValueError(\n      `Expected 'ids' to be an array, but got ${typeof ids}`,\n    );\n  }\n\n  if (ids.length === 0) {\n    throw new ChromaValueError(\"Expected 'ids' to be a non-empty list\");\n  }\n\n  const nonStrings = ids\n    .map((id, i) => [id, i] as [any, number])\n    .filter(([id, _]) => typeof id !== \"string\")\n    .map(([_, i]) => i);\n\n  if (nonStrings.length > 0) {\n    throw new ChromaValueError(\n      `Found non-string IDs at ${nonStrings.join(\", \")}`,\n    );\n  }\n\n  const seen = new Set();\n  const duplicates = ids.filter((id) => {\n    if (seen.has(id)) {\n      return id;\n    }","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/chromadb/src/utils.ts#L178-L214","documentation":"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.","triggerScenarios":"collection.add({ ids: [], documents: [] }); collection.delete({ ids: [] }); a deletion routine computing affected ids and finding none.","commonSituations":"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).","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"],"exampleFix":"// before\nawait collection.delete({ ids: matchedIds }); // matchedIds === []\n// after\nif (matchedIds.length === 0) return { deleted: 0 };\nawait collection.delete({ ids: matchedIds });","handlingStrategy":"validation","validationCode":"if (Array.isArray(ids) && ids.length === 0) return { deleted: 0 };","typeGuard":"const hasIds = (v) => Array.isArray(v) && v.length > 0;","tryCatchPattern":"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; }","preventionTips":["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"],"tags":["chromadb","validation","ids","empty-array"],"backgroundTag":"empty-ids-array","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}