azure-cosmos-db-emulator-docker
azure-cosmos-db-emulator-docker copied to clipboard
Python SDK operations broken with newest vnext-preview image
Describe the bug
Python SDK broken since newest update on vnext-preview tag. Create container operation fails with the error
URL has an invalid label.
To Reproduce Steps to reproduce the behavior: I performed an image update on the vnext-preview tag using
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
This resulted in pulling a new image published 5 days ago:
Digest: sha256:ed599d296267435a7dd4bd347932b8214f51cba109cae236ab83c6ccef009037
Status: Downloaded newer image for mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator vnext-preview ed599d296267 5 days ago 1.23GB
Even though this is not listed on GitHub as a release (maybe an accidental one?).
Then I started the container with:
docker create --name cosmos -p 8081:8081 -p 1234:1234 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
docker start cosmos
At this point I can access the Data Explorer on localhost:1234. However when trying to create a container using Python SDK I get the following error:
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/tracing/decorator.py", line 105, in wrapper_use_tracer
return func(*args, **kwargs)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/database.py", line 272, in create_container
result = self.client_connection.CreateContainer(
database_link=self.database_link, collection=definition, options=request_options, **kwargs
)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_cosmos_client_connection.py", line 534, in CreateContainer
return self.Create(collection, path, "colls", database_id, None, options, **kwargs)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_cosmos_client_connection.py", line 2618, in Create
result, last_response_headers = self.__Post(path, request_params, body, headers, **kwargs)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_cosmos_client_connection.py", line 2837, in __Post
return synchronized_request.SynchronizedRequest(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
client=self,
^^^^^^^^^^^^
...<6 lines>...
**kwargs
^^^^^^^^
)
^
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_synchronized_request.py", line 214, in SynchronizedRequest
return _retry_utility.Execute(
~~~~~~~~~~~~~~~~~~~~~~^
client,
^^^^^^^
...<6 lines>...
**kwargs
^^^^^^^^
)
^
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_retry_utility.py", line 97, in Execute
result = ExecuteFunction(function, global_endpoint_manager, *args, **kwargs)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_retry_utility.py", line 199, in ExecuteFunction
return function(*args, **kwargs)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_synchronized_request.py", line 131, in _Request
response = _PipelineRunFunction(
pipeline_client,
...<4 lines>...
**kwargs
)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_synchronized_request.py", line 183, in _PipelineRunFunction
return pipeline_client._pipeline.run(request, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 240, in run
return first_node.send(pipeline_request)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 96, in send
response = self.next.send(request)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 96, in send
response = self.next.send(request)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 96, in send
response = self.next.send(request)
[Previous line repeated 1 more time]
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_retry_utility.py", line 271, in send
raise err
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/cosmos/_retry_utility.py", line 247, in send
response = self.next.send(request)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 96, in send
response = self.next.send(request)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 96, in send
response = self.next.send(request)
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 96, in send
response = self.next.send(request)
[Previous line repeated 1 more time]
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/_base.py", line 128, in send
self._sender.send(request.http_request, **request.context.options),
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/peti/.pyenv/versions/vms-infra-3.13.2/lib/python3.13/site-packages/azure/core/pipeline/transport/_requests_basic.py", line 409, in send
raise error
azure.core.exceptions.ServiceRequestError: URL has an invalid label.
This worked perfectly fine with the January release. The same thing happens with other operations as well (like create database). The client connection can be created, the error only happens when trying to perform an operation. The client is created like this:
client = cosmos_client.CosmosClient('http://localhost:8081', credential='C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==')
This also works
db = client.get_database_client(db_name)
Any calls to db.create_container however fail with the above error. I also tried db.create_database_if_not_exists which also fails.
Expected behavior SDK calls are performed successfully.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: macOS 15.3.2
- Browser N/A
- Version N/A
- SDK version: azure-cosmos==4.9.0
- SDK language: Python
Additional context I have tried to switch back to the older image, but I have no idea how, as I already deleted the old image (big mistake), and I don't find the tags and hashes for the image anywhere on MCR. Is there a place where we can list the tags and hashes for the releases?
I can confirm that just by switching to the old version the problem is gone. I have used the following command to unblock myself:
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-EN20250122
@conTroll We had an earlier version that had regression and the 20250122 is currently in place. Thank you for your feedback.
Also, we are aware of a known issue with python SDK that for versions > 20250122, query may return nothing. For queries on python SDK, please still use mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-EN20250122 .
I am experiencing the exact same error message when using the python SDK. I tried with using both mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-EN20250122 as suggested as well as the mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview, and both gives the same error.