chroma-core/chroma · error · ValueError
At least one of {', '.join(contains_any)} must be provided
Error message
At least one of {', '.join(contains_any)} must be provided What it means
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.
Source
Thrown at chromadb/api/types.py:498
Validates that the Record is ready to be embedded, i.e. that it contains exactly one of the embeddable fields.
"""
if record_set["embeddings"] is not None:
raise ValueError("Attempting to embed a record that already has embeddings.")
if embeddable_fields is None:
embeddable_fields = get_default_embeddable_record_set_fields()
validate_record_set_contains_one(record_set, embeddable_fields)
def validate_record_set_contains_any(
record_set: BaseRecordSet, contains_any: Set[str]
) -> None:
"""
Validates that at least one of the fields in contains_any is not None.
"""
_validate_record_set_contains(record_set, contains_any)
if not any(record_set[field] is not None for field in contains_any): # type: ignore[literal-required]
raise ValueError(f"At least one of {', '.join(contains_any)} must be provided")
def validate_record_set_contains_one(
record_set: BaseRecordSet, contains_one: Set[str]
) -> None:
"""
Validates that exactly one of the fields in contains_one is not None.
"""
_validate_record_set_contains(record_set, contains_one)
if sum(record_set[field] is not None for field in contains_one) != 1: # type: ignore[literal-required]
raise ValueError(f"Exactly one of {', '.join(contains_one)} must be provided")
def _validate_record_set_contains(
record_set: BaseRecordSet, contains: Set[str]
) -> None:
"""
Validates that all fields in contains are valid fields of the Record.View on GitHub (pinned to aecdd12c8a)
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
Defensive patterns
Strategy: validation
Validate before calling
contains_any = {'documents', 'images', 'uris'}
if all(record_set.get(f) is None for f in contains_any):
raise ValueError(f'nothing to process: provide one of {sorted(contains_any)}')
validate_record_set_contains_any(record_set, contains_any) Type guard
def has_any_field(record_set, fields) -> bool:
return any(record_set.get(f) is not None for f in fields) Try / catch
try:
validate_record_set_contains_any(record_set=rs, contains_any=fields)
except ValueError as e:
if 'At least one of' in str(e): # distinct from 'Exactly one of'
return # nothing to do
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: Framework or tool authors reusing chromadb.api.types validators; test code exercising record-set validation; refactors that set fields to None before validation runs.
Related errors
- Attempting to embed a record that already has embeddings.
- Invalid field in contains: {', '.join(contains)}, available
- Unequal lengths for fields: {error_str}
- Exactly one of {', '.join(contains_one)} must be provided
- Expected IDs to be a list, got {type(ids).__name__} as IDs
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/7377ddf0e8b6f1c6.
Report an issue: GitHub.