question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Throws exception on failure of `az devops user list`

See original GitHub issue

Describe the bug

When I run az devops user list, I get presented with the traceback from an exception.

Command Name az devops user list Extension Name: azure-devops. Version: 0.11.0.

Errors:

The command failed with an unexpected error. Here is the traceback:

The requested resource requires user authentication: https://example.vsaex.visualstudio.com/_apis/UserEntitlements?top=100
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 603, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 661, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 652, in _run_job
    cmd_copy.exception_handler(ex)
  File "/home/andreas/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 26, in azure_devops_exception_handler
    reraise(*sys.exc_info())
  File "/opt/az/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 631, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 305, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 485, in default_command_handler
    return op(**command_args)
  File "/home/andreas/.azure/cliextensions/azure-devops/azext_devops/dev/team/user.py", line 23, in get_user_entitlements
    user_entitlements = client.get_user_entitlements(top=top, skip=skip)
  File "/home/andreas/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/v5_0/member_entitlement_management/member_entitlement_management_client.py", line 138, in get_user_entitlements
    query_parameters=query_parameters)
  File "/home/andreas/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 90, in _send
    response = self._send_request(request=request, headers=headers, content=content, media_type=media_type)
  File "/home/andreas/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 54, in _send_request
    self._handle_error(request, response)
  File "/home/andreas/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 254, in _handle_error
    url=request.url))
azext_devops.devops_sdk.exceptions.AzureDevOpsAuthenticationError: The requested resource requires user authentication: https://example.vsaex.visualstudio.com/_apis/UserEntitlements?top=100

To Reproduce:

Steps to reproduce the behavior.

  • az devops user list

Expected Behavior

If the command fails, it should print a friendly message not throw an exception.

Environment Summary

Linux-4.15.0-58-generic-x86_64-with-debian-buster-sid
Python 3.6.5
Shell: bash

azure-cli 2.0.70 *

Extensions:
azure-devops 0.11.0

Additional Context

I probably do not have the appropriate access rights to something.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gauravsaralMscommented, Aug 29, 2019

@lindhe : Thanks for pointing the intent 😃 yes that is an issue and that will be fixed in next release.

Sorry but not able to help with the auth issue you are facing.

0reactions
lindhecommented, Aug 28, 2019

@lindhe : are you sure you are running both the commands against same organization? because from the logs you shared looks like you don’t have permission to list projects in this org https://gist.github.com/lindhe/6ba001bf74f45b143a7e8d25e6d82d6b#file-user_list_debug-log-L142-L146

I don’t know which permission is required. I’m pretty sure that I should have permission to access it, but I strongly suspect that az have gotten something twisted with which id and org that should be used. However, I’m mainly reporting the error because of getting presented with a traceback, not so much because of me fucking up my logins/permissions. 😃

your org name is “example.visualstudio.com” ?

you can try this link… https://example.vsaex.visualstudio.com/_apis/UserEntitlements?top=100 because this is the exact url which is called by CLI

No, not literally example.visualstudio.com. Because of NDA, I substituted the real org name with example.

I tried the link you suggested, and that worked fine in my browser. Got some JSON with the correct list.

@lindhe : can you share logs from az devops project list --debug as well? This way we can make sure both of your commands are targeting same org

Here: https://gist.github.com/lindhe/02a1cf257906f5b34d262b2fe3feea68

Read more comments on GitHub >

github_iconTop Results From Across the Web

is misspelled or not recognized by the system. - Microsoft Q&A
throws exception : ... I got the Id from the az devops project list during the same session. not-supported-azure. Comment. Comment
Read more >
Multiple DevOps REST methods throwing 'command failed ...
Fix #2: I was working with two different REST requests, one retrieves a simple list of builds, the other retrieves a simple list...
Read more >
Azure DevOps Build Agent not able to access Azure Storage
But when I try to upload the file it throws an error like below. ... default action to apply when no rule matches,...
Read more >
Using Azure CLI with PowerShell: error handling explained
Azure Pipelines has a task for using the Azure CLI, but this only has the options to use the command line (.cmd or...
Read more >
the urban canuk, eh
You can query the list of Builds and then use Timeline API for each build ... Fear not, there's actually a built in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found