{"record":{"id":"7d302cf5e42358fb","repo":"chroma-core/chroma","slug":"limit-limit-must-be-an-integer-got-type-limit","errorCode":null,"errorMessage":"Limit limit must be an integer, got {type(limit).__name__}","messagePattern":"Limit limit must be an integer, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"chromadb/execution/expression/operator.py","lineNumber":580,"sourceCode":"        - {\"offset\": 10} -> Limit(offset=10)\n        - {\"offset\": 10, \"limit\": 20} -> Limit(offset=10, limit=20)\n        - {\"limit\": 20} -> Limit(offset=0, limit=20)\n        \"\"\"\n        if not isinstance(data, dict):\n            raise TypeError(f\"Expected dict for Limit, got {type(data).__name__}\")\n\n        offset = data.get(\"offset\", 0)\n        if not isinstance(offset, int):\n            raise TypeError(\n                f\"Limit offset must be an integer, got {type(offset).__name__}\"\n            )\n        if offset < 0:\n            raise ValueError(f\"Limit offset must be non-negative, got {offset}\")\n\n        limit = data.get(\"limit\")\n        if limit is not None:\n            if not isinstance(limit, int):\n                raise TypeError(\n                    f\"Limit limit must be an integer, got {type(limit).__name__}\"\n                )\n            if limit <= 0:\n                raise ValueError(f\"Limit limit must be positive, got {limit}\")\n\n        # Check for unexpected keys\n        allowed_keys = {\"offset\", \"limit\"}\n        unexpected_keys = set(data.keys()) - allowed_keys\n        if unexpected_keys:\n            raise ValueError(f\"Unexpected keys in Limit dict: {unexpected_keys}\")\n\n        return Limit(offset=offset, limit=limit)\n\n\n@dataclass\nclass Projection:\n    document: bool = False\n    embedding: bool = False","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/execution/expression/operator.py#L562-L598","documentation":"When a 'limit' key is present in the Limit dict it must be a Python int (None is allowed and means no limit). Floats such as 20.0, strings such as '20', and numpy integers (np.int64 is not a subclass of int) all fail isinstance(limit, int) and raise TypeError.","triggerScenarios":"Limit.from_dict({'limit': '20'}); {'limit': 20.0} from a strict JSON decoder; {'limit': np.int64(20)} from numpy sizing math.","commonSituations":"Configs storing limits as strings; numpy arrays/constants feeding pagination sizes; decoders that emit floats for all JSON numbers.","solutions":["Pass a plain Python int: {'limit': 20}.","Convert numpy scalars at the boundary: {'limit': int(n)}.","Coerce numeric strings/whole floats once during config parsing: int(value)."],"exampleFix":"# before\nSearch(limit={'limit': np.int64(20)})   # -> TypeError: got int64\n\n# after\nSearch(limit={'limit': int(n)})","handlingStrategy":"validation","validationCode":"def as_int(value):\n    if isinstance(value, bool):\n        raise TypeError('bool is not a valid limit')\n    if isinstance(value, int):\n        return value\n    if isinstance(value, float) and value.is_integer():\n        return int(value)\n    if hasattr(value, 'item'):  # numpy scalars\n        return int(value.item())\n    raise TypeError(f'cannot coerce {type(value).__name__} to int')\n\nSearch(limit={'limit': as_int(cfg['limit'])})","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Convert numpy scalars with int() before building payloads.","Declare limit fields as integer in config schemas.","Remember limit=None is valid and means unlimited - do not send null-ish strings instead."],"tags":["validation","typeerror","pagination","limit","numpy","chromadb"],"backgroundTag":"type-validation-failed","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}