-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
- Package Name: azure-cosmos
- Package Version: 4.2.0
- Operating System: Arch Linux
- Python Version: Python 3.9.7
Describe the bug
The docs of azure.cosmos.database.DatabaseProxy.get_user_client state the method raises an exception if the given user couldn't be retrieved. On my system such an exception is not thrown unless I call read() on the resulting UserProxy instance
azure.cosmos.database.get_user_client doc string:
"""Get a `UserProxy` for a user with specified ID.
:param user: The ID (name), dict representing the properties or :class:`UserProxy`
instance of the user to be retrieved.
:returns: A `UserProxy` instance representing the retrieved user.
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: If the given user couldn't be retrieved.
:rtype: ~azure.cosmos.UserProxy
"""
To Reproduce
Execute following test script:
import os
from azure.cosmos import CosmosClient
url = os.environ["ACCOUNT_URL"]
key = os.environ["ACCOUNT_KEY"]
client = CosmosClient(url, key)
database = client.create_database("cosmosdb_bug_test_db")
user_proxy = database.get_user_client(
"non-existant-user"
) # this statement does not raise an exception
user = (
user_proxy.read()
) # this statement raises the azure.cosmos.exceptions.CosmosResourceNotFoundError exceptionExpected behavior
L10 raises the exception.
If not, the documentation should be updated to reflect that get_user_client does not actually raise the exception. Similar concerns might exist for other Proxy objects and their doc strings (CosmosClient.get_database_client appears ok).
Additional context
I tested this with mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator running locally, though I expect the same behavior on an Azure hosted cosmosdb.