{"record":{"id":"d600d28bc1534390","repo":"chroma-core/chroma","slug":"api-key-env-var-must-be-provided-in-config","errorCode":null,"errorMessage":"api_key_env_var must be provided in config","messagePattern":"api_key_env_var must be provided in config","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/chroma_cloud_splade_embedding_function.py","lineNumber":155,"sourceCode":"                normalize_sparse_vector(indices=indices, values=values, labels=labels)\n            )\n\n        return normalized_vectors\n\n    @staticmethod\n    def name() -> str:\n        return \"chroma-cloud-splade\"\n\n    @staticmethod\n    def build_from_config(\n        config: Dict[str, Any]\n    ) -> \"SparseEmbeddingFunction[Documents]\":\n        api_key_env_var = config.get(\"api_key_env_var\")\n        model = config.get(\"model\")\n        if model is None:\n            raise ValueError(\"model must be provided in config\")\n        if not api_key_env_var:\n            raise ValueError(\"api_key_env_var must be provided in config\")\n        return ChromaCloudSpladeEmbeddingFunction(\n            api_key_env_var=api_key_env_var,\n            model=ChromaCloudSpladeEmbeddingModel(model),\n            include_tokens=config.get(\"include_tokens\", False),\n        )\n\n    def get_config(self) -> Dict[str, Any]:\n        return {\n            \"api_key_env_var\": self.api_key_env_var,\n            \"model\": self.model.value,\n            \"include_tokens\": self.include_tokens,\n        }\n\n    def validate_config_update(\n        self, old_config: Dict[str, Any], new_config: Dict[str, Any]\n    ) -> None:\n        immutable_keys = {\"include_tokens\", \"model\"}\n        for key in immutable_keys:","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/chroma_cloud_splade_embedding_function.py#L137-L173","documentation":"build_from_config raises ValueError when config.get(\"api_key_env_var\") is falsy (missing, None, or empty string). The env var name is required to resolve credentials when the function is reconstructed, even though the key itself is deliberately not persisted (only the variable name is).","triggerScenarios":"Calling ChromaCloudSpladeEmbeddingFunction.build_from_config(config) where config has no 'api_key_env_var' key or it is set to \"\" — e.g. a config dict assembled by hand that only includes 'model'.","commonSituations":"Manually constructed configs that omit credential-related fields; older persisted configs predating api_key_env_var serialization; copy-pasted examples trimmed for brevity.","solutions":["Add \"api_key_env_var\": \"CHROMA_API_KEY\" (or your custom variable name) to the config.","Round-trip configs via get_config() so all required keys survive.","Ensure the named variable is actually exported at rebuild time, otherwise the constructor will next fail with the API-key-not-found error."],"exampleFix":"# before\nef = ChromaCloudSpladeEmbeddingFunction.build_from_config(\n    {\"model\": \"prithivida/Splade_PP_en_v1\"}  # ValueError: api_key_env_var must be provided\n)\n\n# after\nef = ChromaCloudSpladeEmbeddingFunction.build_from_config({\n    \"model\": \"prithivida/Splade_PP_en_v1\",\n    \"api_key_env_var\": \"CHROMA_API_KEY\",\n})","handlingStrategy":"validation","validationCode":"if not config.get(\"api_key_env_var\"):\n    config[\"api_key_env_var\"] = \"CHROMA_API_KEY\"  # or fail loudly:\n    # raise ValueError(\"config['api_key_env_var'] is required\")\nef = ChromaCloudSpladeEmbeddingFunction.build_from_config(config)","typeGuard":"def is_buildable_splade_config(config: dict) -> bool:\n    return config.get(\"model\") in {m.value for m in ChromaCloudSpladeEmbeddingModel} and bool(config.get(\"api_key_env_var\"))","tryCatchPattern":null,"preventionTips":["Include api_key_env_var whenever you persist or construct an EF config.","Remember only the env var NAME is persisted — keep the variable itself exported.","Validate required keys before calling build_from_config in deserialization code."],"tags":["chroma-cloud","splade","config-validation","deserialization","api-key"],"backgroundTag":"config-validation-failed","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}