{"record":{"id":"7377ddf0e8b6f1c6","repo":"chroma-core/chroma","slug":"at-least-one-of-join-contains-any-must-be","errorCode":null,"errorMessage":"At least one of {', '.join(contains_any)} must be provided","messagePattern":"At least one of (.+?) must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/types.py","lineNumber":498,"sourceCode":"    Validates that the Record is ready to be embedded, i.e. that it contains exactly one of the embeddable fields.\n    \"\"\"\n    if record_set[\"embeddings\"] is not None:\n        raise ValueError(\"Attempting to embed a record that already has embeddings.\")\n    if embeddable_fields is None:\n        embeddable_fields = get_default_embeddable_record_set_fields()\n    validate_record_set_contains_one(record_set, embeddable_fields)\n\n\ndef validate_record_set_contains_any(\n    record_set: BaseRecordSet, contains_any: Set[str]\n) -> None:\n    \"\"\"\n    Validates that at least one of the fields in contains_any is not None.\n    \"\"\"\n    _validate_record_set_contains(record_set, contains_any)\n\n    if not any(record_set[field] is not None for field in contains_any):  # type: ignore[literal-required]\n        raise ValueError(f\"At least one of {', '.join(contains_any)} must be provided\")\n\n\ndef validate_record_set_contains_one(\n    record_set: BaseRecordSet, contains_one: Set[str]\n) -> None:\n    \"\"\"\n    Validates that exactly one of the fields in contains_one is not None.\n    \"\"\"\n    _validate_record_set_contains(record_set, contains_one)\n    if sum(record_set[field] is not None for field in contains_one) != 1:  # type: ignore[literal-required]\n        raise ValueError(f\"Exactly one of {', '.join(contains_one)} must be provided\")\n\n\ndef _validate_record_set_contains(\n    record_set: BaseRecordSet, contains: Set[str]\n) -> None:\n    \"\"\"\n    Validates that all fields in contains are valid fields of the Record.","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/types.py#L480-L516","documentation":"validate_record_set_contains_any (chromadb/api/types.py:489) enforces that at least one of the named record-set fields is not None. It is part of Chroma's reusable validation surface in chromadb.api.types; the only built-in call site is the add path in CollectionCommon.py:236 with contains_any={'ids'}. Because ids is a required argument of add() and single values are auto-wrapped, public-API callers almost never see it - it fires when every field listed in contains_any is None, which in practice means direct use of the validator helpers or custom code that assembles record sets itself.","triggerScenarios":"Calling validate_record_set_contains_any(record_set, {'documents','uris'}) on a record set where both fields are None; a custom ingestion pipeline that builds a record set without ids and reuses Chroma's add-path validation; omitting all named inputs when invoking the helper directly.","commonSituations":"Framework or tool authors reusing chromadb.api.types validators; test code exercising record-set validation; refactors that set fields to None before validation runs.","solutions":["Provide at least one of the fields named in the error message","Before calling the validator, short-circuit when nothing is present: if all(record_set.get(f) is None for f in contains_any): return / raise your own 'nothing to do' error","Derive contains_any from the same constants Chroma uses (e.g. get_default_embeddable_record_set_fields()) so the field list matches your record set"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"contains_any = {'documents', 'images', 'uris'}\nif all(record_set.get(f) is None for f in contains_any):\n    raise ValueError(f'nothing to process: provide one of {sorted(contains_any)}')\nvalidate_record_set_contains_any(record_set, contains_any)","typeGuard":"def has_any_field(record_set, fields) -> bool:\n    return any(record_set.get(f) is not None for f in fields)","tryCatchPattern":"try:\n    validate_record_set_contains_any(record_set=rs, contains_any=fields)\nexcept ValueError as e:\n    if 'At least one of' in str(e):  # distinct from 'Exactly one of'\n        return  # nothing to do\n    raise","preventionTips":["Short-circuit empty inputs before invoking validators","Distinguish this message from 'Exactly one of ...' when matching error strings","Reuse Chroma constants for field-name sets to avoid drift"],"tags":["chromadb","python","validation","record-set","internal-api"],"backgroundTag":"missing-required-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}