Skip to content

[Bug]: Query - In-place mutation of include parameter causes corruption across calls #5857

@Samyak2406

Description

@Samyak2406

What happened?

Problem
The include parameter is mutated in-place without copying, which can cause corruption when the same list object is reused across multiple calls.

Location: chromadb/api/models/CollectionCommon.py:307-314
pythonrequest_include = include  # No copy - just a reference
if "data" in include:
    request_include.append("uris")  # Mutates original

Impact

Shared list objects get permanently modified
Mutations accumulate across function calls
Can trigger validation errors in newer versions with stricter type checking

Reproduction

pythonmy_include = ["embeddings", "documents"]

collection.query(query_texts=["test1"], include=my_include)
# my_include is now mutated

collection.query(query_texts=["test2"], include=my_include)
# Uses corrupted list from previous call

Proposed Fix

pythonrequest_include = list(include) if include else []

Copy the list before any in-place modifications.

Versions

Chroma v1.3.4

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions