{"record":{"id":"ae83bca9ef2951ca","repo":"chroma-core/chroma","slug":"aggregate-dict-must-contain-exactly-one-operator","errorCode":null,"errorMessage":"Aggregate dict must contain exactly one operator, got {len(data)}","messagePattern":"Aggregate dict must contain exactly one operator, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/execution/expression/operator.py","lineNumber":1416,"sourceCode":"        \"\"\"Convert the Aggregate expression to a dictionary for JSON serialization\"\"\"\n        raise NotImplementedError(\"Subclasses must implement to_dict()\")\n\n    @staticmethod\n    def from_dict(data: Dict[str, Any]) -> \"Aggregate\":\n        \"\"\"Create Aggregate expression from dictionary.\n\n        Supports:\n        - {\"$min_k\": {\"keys\": [...], \"k\": n}} -> MinK(keys=[...], k=n)\n        - {\"$max_k\": {\"keys\": [...], \"k\": n}} -> MaxK(keys=[...], k=n)\n        \"\"\"\n        if not isinstance(data, dict):\n            raise TypeError(f\"Expected dict for Aggregate, got {type(data).__name__}\")\n\n        if not data:\n            raise ValueError(\"Aggregate dict cannot be empty\")\n\n        if len(data) != 1:\n            raise ValueError(\n                f\"Aggregate dict must contain exactly one operator, got {len(data)}\"\n            )\n\n        op = next(iter(data.keys()))\n\n        if op == \"$min_k\":\n            keys, k = _parse_k_aggregate(op, data)\n            return MinK(keys=keys, k=k)\n        elif op == \"$max_k\":\n            keys, k = _parse_k_aggregate(op, data)\n            return MaxK(keys=keys, k=k)\n        else:\n            raise ValueError(f\"Unknown aggregate operator: {op}\")\n\n\n@dataclass\nclass MinK(Aggregate):\n    \"\"\"Keep k records with minimum aggregate key values per group\"\"\"","sourceCodeStart":1398,"sourceCodeEnd":1434,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/execution/expression/operator.py#L1398-L1434","documentation":"Error \"Aggregate dict must contain exactly one operator, got {len(data)}\" thrown in chroma-core/chroma.","triggerScenarios":"Thrown at chromadb/execution/expression/operator.py:1416 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}