{"record":{"id":"eebfe43ba298e528","repo":"microsoft/semantic-kernel","slug":"unsupported-constant-type-type-value-eebfe4","errorCode":null,"errorMessage":"Unsupported constant type: {type(value)}","messagePattern":"Unsupported constant type: (.+?)","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/chroma.py","lineNumber":432,"sourceCode":"                        f\"Field '{node.attr}' not in data model (storage property names are used).\"\n                    )\n                return node.attr\n            case ast.Name():\n                # Only allow names that are in the data model\n                if node.id not in self.definition.storage_names:\n                    raise VectorStoreOperationException(\n                        f\"Field '{node.id}' not in data model (storage property names are used).\"\n                    )\n                return node.id\n            case ast.Constant():\n                value = node.value\n                if isinstance(value, str):\n                    return value.replace(\"'\", \"''\")\n                if isinstance(value, bytes):\n                    return value.decode(\"utf-8\").replace(\"'\", \"''\")\n                if isinstance(value, (int, float, bool)) or value is None:\n                    return value\n                raise VectorStoreOperationException(f\"Unsupported constant type: {type(value)}\")\n        raise NotImplementedError(f\"Unsupported AST node: {type(node)}\")\n\n\n@release_candidate\nclass ChromaStore(VectorStore):\n    \"\"\"Chroma vector store.\"\"\"\n\n    client: ClientAPI\n\n    def __init__(\n        self,\n        persist_directory: str | None = None,\n        client_settings: \"Settings | None\" = None,\n        client: ClientAPI | None = None,\n        embedding_generator: EmbeddingGeneratorBase | None = None,\n        **kwargs: Any,\n    ):\n        \"\"\"Initialize the Chroma vector store.\"\"\"","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/chroma.py#L414-L450","documentation":"A VectorStoreOperationException raised by _lambda_parser for an ast.Constant whose value is not str, bytes, int, float, bool, or None. The translator only knows how to emit these primitive types into a Chroma where-filter; any other constant (e.g. a tuple, list, dict, frozenset, complex, or a custom object literal) is rejected.","triggerScenarios":"Using a list/tuple/set/dict literal directly in a filter comparison, e.g. lambda x: x.tag == [\"a\",\"b\"] or lambda x: x.val == (1,2). Complex numbers or other non-primitive literals also trigger it.","commonSituations":"Attempting membership/multi-value equality with a list literal (unsupported — see also error 1286 for 'in'); embedding a dataclass/tuple as a comparison value.","solutions":["Compare against a primitive scalar (str/int/float/bool/None).","For multi-value matching, expand to ORed equality checks (one comparison per value), since Chroma where-filters are scalar-based."],"exampleFix":"// before\nlambda x: x.tag == [\"a\", \"b\"]\n// after\nlambda x: (x.tag == \"a\") or (x.tag == \"b\")","handlingStrategy":"type-guard","validationCode":"import ast\nALLOWED_CONST = (str, bytes, int, float, bool, type(None))\ntree = ast.parse(filter_lambda_src, mode=\"eval\")\nconsts = [n.value for n in ast.walk(tree) if isinstance(n, ast.Constant)]\nassert all(isinstance(c, ALLOWED_CONST) for c in consts), \"Filter constants must be str/bytes/int/float/bool/None\"","typeGuard":"ALLOWED_CONST = (str, bytes, int, float, bool, type(None))\n\ndef is_supported_filter_constant(value) -> bool:\n    return isinstance(value, ALLOWED_CONST)","tryCatchPattern":"from semantic_kernel.exceptions.vector_store_exceptions import VectorStoreOperationException\ntry:\n    results = await collection.vectorized_search(vector=v, options=opts)\nexcept VectorStoreOperationException as e:\n    if \"Unsupported constant type\" in str(e):\n        # replace list/tuple literals with ORed scalar comparisons\n        ...","preventionTips":["Compare fields only to scalar primitives (str/int/float/bool/None).","Expand list/tuple comparisons into ORed equalities."],"tags":["chroma","vector-store","filter","lambda","type"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}