{"record":{"id":"6336903aa06a935f","repo":"chroma-core/chroma","slug":"include-item-cannot-be-one-of-join-dissalowe","errorCode":null,"errorMessage":"Include item cannot be one of {', '.join(dissalowed)}, got {item}","messagePattern":"Include item cannot be one of (.+?), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/types.py","lineNumber":1353,"sourceCode":"def validate_include(include: Include, dissalowed: Optional[Include] = None) -> None:\n    \"\"\"Validates include to ensure it is a list of strings. Since get does not allow distances, allow_distances is used\n    to control if distances is allowed\"\"\"\n\n    if not isinstance(include, list):\n        raise ValueError(f\"Expected include to be a list, got {include}\")\n    for item in include:\n        if not isinstance(item, str):\n            raise ValueError(f\"Expected include item to be a str, got {item}\")\n\n        # Get the valid items from the Literal type inside the List\n        valid_items = get_args(get_args(Include)[0])\n        if item not in valid_items:\n            raise ValueError(\n                f\"Expected include item to be one of {', '.join(valid_items)}, got {item}\"\n            )\n\n        if dissalowed is not None and any(item == e for e in dissalowed):\n            raise ValueError(\n                f\"Include item cannot be one of {', '.join(dissalowed)}, got {item}\"\n            )\n\n\ndef validate_n_results(n_results: int) -> int:\n    \"\"\"Validates n_results to ensure it is a positive Integer. Since hnswlib does not allow n_results to be negative.\"\"\"\n    # Check Number of requested results\n    if not isinstance(n_results, int):\n        raise ValueError(\n            f\"Expected requested number of results to be a int, got {n_results}\"\n        )\n    if n_results <= 0:\n        raise TypeError(\n            f\"Number of requested results {n_results}, cannot be negative, or zero.\"\n        )\n    return n_results\n\n","sourceCodeStart":1335,"sourceCodeEnd":1371,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/types.py#L1335-L1371","documentation":"Some call sites pass a disallowed set to validate_include (note the misspelled parameter name 'dissalowed' in the source). Collection.get() disallows \"distances\" because distances only exist for nearest-neighbor queries, so get(include=[\"distances\"]) raises this ValueError. Query() passes no disallowed items.","triggerScenarios":"collection.get(ids=[...], include=[\"documents\", \"distances\"]) or collection.get(where=..., include=[\"distances\"]). Any shared include constant (e.g. IncludeMetadataDocumentsEmbeddingsDistances) reused for both query and get will trip this on the get path.","commonSituations":"Sharing one INCLUDE_WITH_DISTANCES constant between query() and get() code paths; refactoring a query into a get (by id) and keeping the old include list; assuming distances are computable for direct fetches.","solutions":["Remove \"distances\" from include when calling collection.get(); distances are only valid in collection.query()","Use separate constants: one for get (documents/metadatas/embeddings/uris/data) and one for query (adds distances)","If you need similarity scores, switch the call to query() with query_embeddings instead of get()"],"exampleFix":"# before\nresults = collection.get(ids=[\"1\", \"2\"], include=[\"documents\", \"distances\"])\n\n# after\nresults = collection.get(ids=[\"1\", \"2\"], include=[\"documents\"])\n# distances only via query:\n# results = collection.query(query_embeddings=[emb], n_results=2, include=[\"documents\", \"distances\"])","handlingStrategy":"validation","validationCode":"def include_for_call(include: list[str], *, is_query: bool) -> list[str]:\n    if not is_query:\n        include = [i for i in include if i != \"distances\"]  # get() cannot return distances\n    return include\n\nres = collection.get(ids=ids, include=include_for_call(include, is_query=False))\nres = collection.query(query_embeddings=[q], n_results=5, include=include_for_call(include, is_query=True))","typeGuard":"def distances_allowed(method: str) -> bool:\n    return method == \"query\"\n\ndef safe_include(include: list[str], method: str) -> bool:\n    return \"distances\" not in include or distances_allowed(method)","tryCatchPattern":"try:\n    res = collection.get(ids=ids, include=include)\nexcept ValueError as e:\n    if \"Include item cannot be one of\" in str(e) and \"distances\" in str(e):\n        include = [i for i in include if i != \"distances\"]\n        res = collection.get(ids=ids, include=include)\n    else:\n        raise","preventionTips":["Keep separate include constants for get() vs query()","Remember distances are a similarity concept: only nearest-neighbor queries have them","Switch to query(query_embeddings=...) when scores are required for known ids"],"tags":["chromadb","include-parameter","distances","get-vs-query"],"backgroundTag":"invalid-query-parameter","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}