Skip to content

azure.cosmos.database.DatabaseProxy.get_user_client does not raise CosmosHttpResponseError if the given user couldn't be retrieved. #21377

@fvdnabee

Description

@fvdnabee
  • 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 exception

Expected 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Cosmoscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions