{"record":{"id":"268ed798704c3bb4","repo":"chroma-core/chroma","slug":"groupby-aggregate-must-be-a-dict-got-type-aggreg","errorCode":null,"errorMessage":"GroupBy aggregate must be a dict, got {type(aggregate_data).__name__}","messagePattern":"GroupBy aggregate must be a dict, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"chromadb/execution/expression/operator.py","lineNumber":1530,"sourceCode":"        # Empty dict returns default GroupBy (no grouping)\n        if not data:\n            return GroupBy()\n\n        # Non-empty dict requires keys and aggregate\n        if \"keys\" not in data:\n            raise ValueError(\"GroupBy requires 'keys' field\")\n        if \"aggregate\" not in data:\n            raise ValueError(\"GroupBy requires 'aggregate' field\")\n\n        keys = data[\"keys\"]\n        if not isinstance(keys, (list, tuple)):\n            raise TypeError(f\"GroupBy keys must be a list, got {type(keys).__name__}\")\n        if not keys:\n            raise ValueError(\"GroupBy keys cannot be empty\")\n\n        aggregate_data = data[\"aggregate\"]\n        if not isinstance(aggregate_data, dict):\n            raise TypeError(\n                f\"GroupBy aggregate must be a dict, got {type(aggregate_data).__name__}\"\n            )\n        aggregate = Aggregate.from_dict(aggregate_data)\n\n        return GroupBy(keys=_strings_to_keys(keys), aggregate=aggregate)\n","sourceCodeStart":1512,"sourceCodeEnd":1536,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/execution/expression/operator.py#L1512-L1536","documentation":"Raised by GroupBy.from_dict when the 'aggregate' field is not a dict — e.g. a string operator name was passed instead of an operator mapping like {\"$min_k\": {...}} that Aggregate.from_dict can parse.","triggerScenarios":"Thrown at chromadb/execution/expression/operator.py:1530 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass aggregate as a dict, e.g. {\"$min_k\": {\"keys\": [\"#score\"], \"k\": 3}}","Serialize an Aggregate object with to_dict() instead of passing the object itself"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","contentChangedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}