{"record":{"id":"5f38799bcd458dd4","repo":"chroma-core/chroma","slug":"op-k-must-be-an-integer-got-type-k-name","errorCode":null,"errorMessage":"{op} k must be an integer, got {type(k).__name__}","messagePattern":"(.+?) k must be an integer, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"chromadb/execution/expression/operator.py","lineNumber":1371,"sourceCode":"        ValueError: If required fields are missing or invalid\n    \"\"\"\n    agg_data = data[op]\n    if not isinstance(agg_data, dict):\n        raise TypeError(f\"{op} requires a dict, got {type(agg_data).__name__}\")\n    if \"keys\" not in agg_data:\n        raise ValueError(f\"{op} requires 'keys' field\")\n    if \"k\" not in agg_data:\n        raise ValueError(f\"{op} requires 'k' field\")\n\n    keys = agg_data[\"keys\"]\n    if not isinstance(keys, (list, tuple)):\n        raise TypeError(f\"{op} keys must be a list, got {type(keys).__name__}\")\n    if not keys:\n        raise ValueError(f\"{op} keys cannot be empty\")\n\n    k = agg_data[\"k\"]\n    if not isinstance(k, int):\n        raise TypeError(f\"{op} k must be an integer, got {type(k).__name__}\")\n    if k <= 0:\n        raise ValueError(f\"{op} k must be positive, got {k}\")\n\n    return _strings_to_keys(keys), k\n\n\n@dataclass\nclass Aggregate:\n    \"\"\"Base class for aggregation expressions within groups.\n\n    Aggregations determine which records to keep from each group:\n    - MinK: Keep k records with minimum values (ascending order)\n    - MaxK: Keep k records with maximum values (descending order)\n\n    Examples:\n        # Keep top 3 by score per group (single key)\n        MinK(keys=Key.SCORE, k=3)\n","sourceCodeStart":1353,"sourceCodeEnd":1389,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/execution/expression/operator.py#L1353-L1389","documentation":"Error \"{op} k must be an integer, got {type(k).__name__}\" thrown in chroma-core/chroma.","triggerScenarios":"Thrown at chromadb/execution/expression/operator.py:1371 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"}