Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throws exception on failure of az devops user list #759

Closed
lindhe opened this issue Aug 23, 2019 · 11 comments · Fixed by #769
Closed

Throws exception on failure of az devops user list #759

lindhe opened this issue Aug 23, 2019 · 11 comments · Fixed by #769

Comments

@lindhe
Copy link

lindhe commented Aug 23, 2019

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.

@gauravsaralMs
Copy link
Contributor

gauravsaralMs commented Aug 27, 2019

@lindhe
Copy link
Author

lindhe commented Aug 27, 2019

@gauravsaralMs at least az login. I know that I have run az devops login too at some point, but not sure if it's in this session. How can I check that?

@gauravsaralMs
Copy link
Contributor

@lindhe : unfortunately you can not check az devops login history.
can you do az devops login again and try?
The error you are getting tells that you have not logged in

@lindhe
Copy link
Author

lindhe commented Aug 27, 2019

Will do! Probably tomorrow.

@lindhe
Copy link
Author

lindhe commented Aug 28, 2019

Now I have tried after running both az login and az devops login, and the issue persists.

@gauravsaralMs
Copy link
Contributor

gauravsaralMs commented Aug 28, 2019

@lindhe : 2 asks in that case

  1. can you try running this same command with --debug and share the logs?
  2. can you try running some other command like az devops project list --debug and check if actually have access the org or not (and share the logs)?

@lindhe
Copy link
Author

lindhe commented Aug 28, 2019

I'll need to redact some parts, for confidentiality. But here you go.

  1. I put the log here: https://gist.github.com/lindhe/6ba001bf74f45b143a7e8d25e6d82d6b

  2. Running az devops project list looks good.

[
  {
    "abbreviation": null,
    "defaultTeamImageUrl": null,
    "description": "redacted",
    "id": "redacted",
    "lastUpdateTime": "2019-07-29T07:14:10.32Z",
    "name": "redacted",
    "revision": 418211976,
    "state": "wellFormed",
    "url": "redacted",
    "visibility": "private"
  }
]

@gauravsaralMs
Copy link
Contributor

gauravsaralMs commented 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

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

@gauravsaralMs
Copy link
Contributor

@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

@lindhe
Copy link
Author

lindhe commented 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

@gauravsaralMs
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants