Skip to content

Missing comma breaks cosmos.azure.aio.CosmosClient.from_connection_string() #22514

Description

@taybin
  • Package Name: azure-cosmos
  • Package Version: 4.3.0b1
  • Operating System:
  • Python Version: 3.9

Describe the bug
A comma is missing at the end of line 162:

return cls(
url=settings['AccountEndpoint'],
credential=credential or settings['AccountKey'],
consistency_level=kwargs.get('consistency_level', 'Session')
**kwargs
)

This results in python trying to use the ** operator on a string and a dict and it throws an exception.

To Reproduce

  1. Call the function cosmos.aure.aio.CosmosClient.from_connection_string()

Expected behavior
The function should not throw an exception

Additional context
Full stack trace:

[2022-01-14T19:46:15.342Z] Exception: TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'dict'
[2022-01-14T19:46:15.342Z] Stack:   File "/usr/local/Cellar/azure-functions-core-tools@4/4.0.3971/workers/python/3.9/OSX/X64/azure_functions_worker/dis
patcher.py", line 305, in _handle__function_load_request
[2022-01-14T19:46:15.342Z]     func = loader.load_function(
[2022-01-14T19:46:15.342Z]   File "/usr/local/Cellar/azure-functions-core-tools@4/4.0.3971/workers/python/3.9/OSX/X64/azure_functions_worker/utils/wrap
pers.py", line 40, in call
[2022-01-14T19:46:15.342Z]     return func(*args, **kwargs)
[2022-01-14T19:46:15.342Z]   File "/usr/local/Cellar/azure-functions-core-tools@4/4.0.3971/workers/python/3.9/OSX/X64/azure_functions_worker/loader.py"
, line 85, in load_function
[2022-01-14T19:46:15.342Z]     mod = importlib.import_module(fullmodname)
[2022-01-14T19:46:15.342Z]   File "/Users/trutkin/.asdf/installs/python/3.9.7/lib/python3.9/importlib/__init__.py", line 127, in import_module
[2022-01-14T19:46:15.342Z]     return _bootstrap._gcd_import(name[level:], package, level)
[2022-01-14T19:46:15.342Z]   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
[2022-01-14T19:46:15.342Z]   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
[2022-01-14T19:46:15.342Z]   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
[2022-01-14T19:46:15.342Z]   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
[2022-01-14T19:46:15.342Z]   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
[2022-01-14T19:46:15.342Z]   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
[2022-01-14T19:46:15.342Z]   File "/Users/trutkin/src/udm_v2/src/function_apps/projection_handler/projection_handler/__init__.py", line 35, in <module>
[2022-01-14T19:46:15.342Z]     cosmos_client = CosmosClient.from_connection_string(DOCUMENTDB_CONNSTR)
[2022-01-14T19:46:15.342Z]   File "/Users/trutkin/src/udm_v2/src/function_apps/projection_handler/.venv/lib/python3.9/site-packages/azure/cosmos/aio/co
smos_client.py", line 180, in from_connection_string
[2022-01-14T19:46:15.342Z]     consistency_level=kwargs.get("consistency_level", "Session") ** kwargs,
[2022-01-14T19:46:15.342Z] .

Running a linter on python code is very helpful for catching these sort of issues.

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions