{"record":{"id":"c160ce0aa6c3123b","repo":"microsoft/semantic-kernel","slug":"failed-to-get-database-proxy-for-id","errorCode":null,"errorMessage":"Failed to get database proxy for '{id}'.","messagePattern":"Failed to get database proxy for '(.+?)'\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":644,"sourceCode":"            return True\n        except CosmosResourceNotFoundError:\n            return False\n        except Exception as e:\n            raise VectorStoreOperationException(\n                f\"Failed to check if database '{self.database_name}' exists, with message {e}\"\n            ) from e\n\n    async def _get_database_proxy(self, **kwargs) -> DatabaseProxy:\n        \"\"\"Gets the database proxy.\"\"\"\n        try:\n            if await self._does_database_exist():\n                return self.cosmos_client.get_database_client(self.database_name)\n\n            if self.create_database:\n                return await self.cosmos_client.create_database(self.database_name, **kwargs)\n            raise VectorStoreOperationException(f\"Database '{self.database_name}' does not exist.\")\n        except Exception as e:\n            raise VectorStoreOperationException(f\"Failed to get database proxy for '{id}'.\") from e\n\n    async def _get_container_proxy(self, container_name: str, **kwargs) -> ContainerProxy:\n        \"\"\"Gets the container proxy.\"\"\"\n        try:\n            database_proxy = await self._get_database_proxy(**kwargs)\n            return database_proxy.get_container_client(container_name)\n        except Exception as e:\n            raise VectorStoreOperationException(f\"Failed to get container proxy for '{container_name}'.\") from e\n\n\n# region: NoSQL Collection\n\n\n@release_candidate\nclass CosmosNoSqlCollection(\n    CosmosNoSqlBase,\n    VectorStoreCollection[TNoSQLKey, TModel],\n    VectorSearch[TNoSQLKey, TModel],","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L626-L662","documentation":"_get_database_proxy wraps its body in try/except and re-wraps any unhandled exception as VectorStoreOperationException. NOTE: the message references '{id}', a variable that is not defined in scope (likely a copy-paste bug; intended is self.database_name). The chained __cause__ holds the real error.","triggerScenarios":"Raised in _get_database_proxy's except block when an exception escapes the existence check and create path. Because the message uses an undefined 'id', in practice this either NameErrors or surfaces a confusing message; the underlying cause is what matters.","commonSituations":"This is effectively a fallback catch for _does_database_exist or create_database failures not already handled. In practice you'll usually see errors 1252/1253 first. If you see this one, inspect __cause__.","solutions":["Inspect exc.__cause__ to identify the real failure (network, auth, throttling, etc.).","File/fix the bug: replace '{id}' with '{self.database_name}' in the message for clarity.","Address the underlying cause (credentials, connectivity, provisioning, RU)."],"exampleFix":"// before\nraise VectorStoreOperationException(f\"Failed to get database proxy for '{id}'.\") from e\n// after\nraise VectorStoreOperationException(f\"Failed to get database proxy for '{self.database_name}'.\") from e","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    proxy = await store._get_database_proxy()\nexcept VectorStoreOperationException as e:\n    cause = e.__cause__  # real underlying error\n    # address based on cause type\n","preventionTips":["Inspect __cause__ rather than the (buggy) top-level message.","Patch the message locally: replace '{id}' with '{self.database_name}' and report upstream.","Centralize cause classification for all VectorStoreOperationException catches."],"tags":["azure-cosmos-db","vector-store","runtime","bug","network"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}