{"record":{"id":"cf22a043f400c28f","repo":"chroma-core/chroma","slug":"source-key-cannot-begin-with-the-only-valid-k","errorCode":null,"errorMessage":"source_key cannot begin with '#'. The only valid key starting with '#' is Key.DOCUMENT or '#document'.","messagePattern":"source_key cannot begin with '#'\\. The only valid key starting with '#' is Key\\.DOCUMENT or '#document'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/types.py","lineNumber":1716,"sourceCode":"    @field_validator(\"source_key\", mode=\"before\")\n    @classmethod\n    def validate_source_key_field(cls, v: Any) -> Optional[str]:\n        \"\"\"Convert Key objects to strings automatically. Accepts both str and Key types.\"\"\"\n        if v is None:\n            return None\n        # Import Key at runtime to avoid circular import\n        from chromadb.execution.expression.operator import Key as KeyType\n\n        if isinstance(v, KeyType):\n            v = v.name  # Extract string from Key\n        elif isinstance(v, str):\n            pass  # Already a string\n        else:\n            raise ValueError(f\"source_key must be str or Key, got {type(v).__name__}\")\n\n        # Validate: only #document is allowed if key starts with #\n        if v.startswith(\"#\") and v != \"#document\":\n            raise ValueError(\n                \"source_key cannot begin with '#'. \"\n                \"The only valid key starting with '#' is Key.DOCUMENT or '#document'.\"\n            )\n\n        return v  # type: ignore[no-any-return]\n\n    @field_validator(\"embedding_function\", mode=\"before\")\n    @classmethod\n    def validate_embedding_function_field(cls, v: Any) -> Any:\n        # Use the existing validate_embedding_function for proper validation\n        if v is None:\n            return v\n        if callable(v):\n            # Use the existing validation function\n            validate_embedding_function(v)\n            return v\n        raise ValueError(\"embedding_function must be callable or None\")\n","sourceCodeStart":1698,"sourceCodeEnd":1734,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/types.py#L1698-L1734","documentation":"Error \"source_key cannot begin with '#'. The only valid key starting with '#' is Key.DOCUMENT or '#document'.\" thrown in chroma-core/chroma.","triggerScenarios":"Thrown at chromadb/api/types.py:1716 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"}