The problem involves a walkthrough for using the MSGraph SDK to build Python apps, (https://learn.microsoft.com/en-us/graph/tutorials/python?tabs=aad). For some reason this runs perfectly fine on my laptop (windows 11, Python 3.11.6, msgraph-sdk version 1.0.0a16, azure-identity version 1.14.1), but returns a ValueError (expected 2, got 1) when run on my desktop (windows 10, Python 3.11.6, msgraph-sdk version 1.0.0a16, azure-identity version 1.14.1). This was tested on my associates desktop (windows 11, same everything else) and it returned the same error with the same stack.
Code snippet in question:
async def get_user(self):
# Only request specific properties using $select
query_params = UserItemRequestBuilder.UserItemRequestBuilderGetQueryParameters(
select=['displayName', 'mail', 'userPrincipalName']
)
request_config = UserItemRequestBuilder.UserItemRequestBuilderGetRequestConfiguration(
query_parameters=query_params
)
user = await self.user_client.me.get(request_configuration=request_config)
Stack Traceback
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\runpy.py", line 88, in _run_code
exec(code, run_globals)
File "c:\Users\jfarr\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>
cli.main()
File "c:\Users\jfarr\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\jfarr\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "c:\Users\jfarr\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\jfarr\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\Users\jfarr\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "C:\Users\jfarr\OneDrive\Documents\GitHub\SwordPhish\python_server\src\main.py", line 96, in <module>
asyncio.run(main())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\jfarr\OneDrive\Documents\GitHub\SwordPhish\python_server\src\main.py", line 18, in main
await greet_user(graph)
File "C:\Users\jfarr\OneDrive\Documents\GitHub\SwordPhish\python_server\src\main.py", line 51, in greet_user
user = await graph.get_user()
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jfarr\OneDrive\Documents\GitHub\SwordPhish\python_server\src\api_outlook.py", line 49, in get_user
user = await self.user_client.me.get(request_configuration=request_config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jfarr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\msgraph\generated\users\item\user_item_request_builder.py", line 155, in get
return await self.request_adapter.send_async(request_info, User, error_mapping)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jfarr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\kiota_http\httpx_request_adapter.py", line 162, in send_async
parent_span = self.start_tracing_span(request_info, "send_async")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jfarr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\kiota_http\httpx_request_adapter.py", line 131, in start_tracing_span
uri_template = ParametersNameDecodingHandler.decode_uri_encoded_string(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jfarr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\kiota_http\middleware\parameters_name_decoding_handler.py", line 92, in decode_uri_encoded_string
name, value = name_value.split('=')
^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
I tried uninstalling and reinstalling everything, trying different combinations of versions hoping that one would be the magic ticket. Still very unsure of what is so different about the environment on my laptop besides the obvious difference in windows versions. However, that does not explain why this happened on my colleagues desktop as well so I am unsure of what to do next. Any help is greatly appreciated!
This error is caused by something taking in 2 pieces of data but only 1 is being provided, if user is a tuple or list or other object this could be cause by one of the values inside of the self.user_client.me.get function not being passed into the object and instead it is just trying to pass a single value, but another function that later uses the tuple expects 2 values if that makes sense, without more context about what that function returns its hard to tell.
The change accross computer may cause this as some libarys or SDK resources may behave different on different OS versions.