{"record":{"id":"22d596dff8462048","repo":"chroma-core/chroma","slug":"at-least-one-of-recordsetfields-join-must","errorCode":null,"errorMessage":"At least one of ${recordSetFields.join(\", \")} must be provided","messagePattern":"At least one of (.+?) must be provided","errorType":"validation","errorClass":"ChromaValueError","httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/chromadb/src/utils.ts","lineNumber":96,"sourceCode":"  }\n  return undefined;\n};\n\n/**\n * Validates that all arrays in a RecordSet have consistent lengths.\n * @param recordSet - The record set to validate\n * @throws ChromaValueError if arrays have inconsistent lengths or are empty\n */\nexport const validateRecordSetLengthConsistency = (recordSet: RecordSet) => {\n  const lengths: [string, number][] = Object.entries(recordSet)\n    .filter(\n      ([field, value]) =>\n        recordSetFields.includes(field) && value !== undefined,\n    )\n    .map(([field, value]) => [field, value.length]);\n\n  if (lengths.length === 0) {\n    throw new ChromaValueError(\n      `At least one of ${recordSetFields.join(\", \")} must be provided`,\n    );\n  }\n\n  const zeroLength = lengths\n    .filter(([_, length]) => length === 0)\n    .map(([field, _]) => field);\n  if (zeroLength.length > 0) {\n    throw new ChromaValueError(\n      `Non-empty lists are required for ${zeroLength.join(\", \")}`,\n    );\n  }\n\n  if (new Set(lengths.map(([_, length]) => length)).size > 1) {\n    throw new ChromaValueError(\n      `Unequal lengths for fields ${lengths\n        .map(([field, _]) => field)\n        .join(\", \")}`,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/chromadb/src/utils.ts#L78-L114","documentation":"ChromaValueError thrown by validateRecordSetLengthConsistency (utils.ts:87), called at the top of Collection.prepareRecords — the shared preparation step for collection.add() and collection.update(). Every record-set field (ids, embeddings, metadatas, documents, uris) was undefined/absent, so there is nothing to insert or update and no length to validate against. Thrown client-side before any network traffic.","triggerScenarios":"await collection.add({ metadatas: undefined, documents: undefined, ids: undefined }) — i.e. an object where all five recordSetFields are undefined; also collection.add({}) or passing an accidentally-empty object built from empty spreads.","commonSituations":"Building a RecordSet dynamically (e.g. filtering rows then spreading) and every field ends up undefined; an empty upstream batch from a loader that yields zero records; typos like {ID: [...]} (wrong casing) leaving the real fields undefined.","solutions":["Ensure at least one of ids, embeddings, metadatas, documents, uris is a non-undefined array — normally ids is required for add/update anyway","Skip the API call entirely when the incoming batch is empty: if (!batch.ids?.length) return","Check field spelling/casing against the RecordSet type (ids, documents, metadatas, embeddings, uris)"],"exampleFix":"// before\nawait collection.add({});\n// after\nif (!records.ids?.length) return; // nothing to add\nawait collection.add({ ids: records.ids, documents: records.documents });","handlingStrategy":"validation","validationCode":"const FIELDS = ['ids','embeddings','metadatas','documents','uris'];\nfunction hasAnyRecordSetField(rs) { return FIELDS.some(f => rs[f] !== undefined); }","typeGuard":"function isNonEmptyRecordSet(rs) { return FIELDS.some(f => Array.isArray(rs[f]) && rs[f].length > 0); }","tryCatchPattern":"try { await collection.add(rs); } catch (e) { if (e instanceof ChromaValueError && /At least one of/.test(e.message)) return; else throw e; }","preventionTips":["Early-return on empty batches at the ingestion boundary","Type batch builders to require at least ids","Spell-check field names against RecordSet (ids, documents, metadatas, embeddings, uris)"],"tags":["chromadb","validation","recordset","client-side-validation"],"backgroundTag":"missing-required-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}