{"record":{"id":"46cbc7ca08de0e43","repo":"chroma-core/chroma","slug":"attempting-to-embed-a-record-that-already-has-embe","errorCode":null,"errorMessage":"Attempting to embed a record that already has embeddings.","messagePattern":"Attempting to embed a record that already has embeddings\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/types.py","lineNumber":483,"sourceCode":"        raise ValueError(f\"Non-empty lists are required for {zero_lengths}\")\n\n    if len(set(lengths)) > 1:\n        error_str = \", \".join(\n            f\"{key}: {len(lst)}\"\n            for key, lst in record_set.items()\n            if lst is not None  # type: ignore[arg-type]\n        )\n        raise ValueError(f\"Unequal lengths for fields: {error_str}\")\n\n\ndef validate_record_set_for_embedding(\n    record_set: BaseRecordSet, embeddable_fields: Optional[Set[str]] = None\n) -> None:\n    \"\"\"\n    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(","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/types.py#L465-L501","documentation":"validate_record_set_for_embedding (chromadb/api/types.py:476) is run on record sets that are about to be embedded. Its first invariant is that the record set does not already carry embeddings - Chroma cannot mix 'embed this for me' with 'use my vectors'. In the current code base every public entry point (add/upsert/update/query in chromadb/api/models/CollectionCommon.py) only invokes this validator when embeddings is None, so hitting this message in practice means the validator was called directly on a pre-embedded record set, typically from custom code reusing the chromadb.api.types helpers.","triggerScenarios":"Calling chromadb.api.types.validate_record_set_for_embedding on a record set whose 'embeddings' key is already populated; passing a pre-embedded record set into a custom ingestion pipeline that re-validates it for embedding. Through the public API the equivalent user mistake (supplying both embeddings and documents to the same call) is caught by other checks or resolved by using the supplied embeddings.","commonSituations":"Teams wrapping Chroma's internal validation helpers in their own ingestion frameworks; upgrades across Chroma versions where these invariants moved between modules; copy-pasting internal example code that builds record sets manually.","solutions":["If you already have vectors, pass embeddings= to add/upsert/query - no embedding step runs and the validator is never reached","In custom code mirroring CollectionCommon, guard the call: if record_set['embeddings'] is None: validate_record_set_for_embedding(...)","Leave the 'embeddings' key None until after the embedding step, and populate it only afterwards"],"exampleFix":"# before (custom pipeline)\nvalidate_record_set_for_embedding(record_set=rs)  # rs['embeddings'] already set\n\n# after\nif rs['embeddings'] is None:\n    validate_record_set_for_embedding(record_set=rs)\n    rs['embeddings'] = embed(rs)","handlingStrategy":"validation","validationCode":"if query_embeddings is not None:\n    results = collection.query(query_embeddings=query_embeddings, n_results=k)\nelse:\n    results = collection.query(query_texts=texts, n_results=k)","typeGuard":"def needs_client_embedding(record_set) -> bool:\n    return record_set.get('embeddings') is None","tryCatchPattern":"try:\n    validate_record_set_for_embedding(record_set=rs)\nexcept ValueError as e:\n    if 'already has embeddings' in str(e):\n        # skip embedding, use the existing vectors\n        pass\n    raise","preventionTips":["Never pass embeddings together with content meant to be embedded","Keep EF-backed and vector-backed search in separate code paths","In custom pipelines, guard validator calls with 'if rs['embeddings'] is None'"],"tags":["chromadb","python","embeddings","validation","internal-api"],"backgroundTag":"embedding-input-conflict","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}