Azure / azure-cli

Azure Command-Line Interface
MIT License
4.04k stars 3.01k forks source link

az ad sp owner list TypeError: Object of type 'bytearray' is not JSON serializable #16123

Open travis-crowder-kr opened 4 years ago

travis-crowder-kr commented 4 years ago

az ad sp owner list TypeError: Object of type 'bytearray' is not JSON serializable

Command Name az ad sp owner list

Errors:

Object of type 'bytearray' is not JSON serializable
Traceback (most recent call last):
Local\Temp\pip-unpacked-wheel-2lthyver\knack\cli.py, ln 221, in invoke
Local\Temp\pip-unpacked-wheel-2lthyver\knack\output.py, ln 149, in out
Local\Temp\pip-unpacked-wheel-2lthyver\knack\output.py, ln 41, in format_json
json\__init__.py, ln 238, in dumps
json\encoder.py, ln 201, in encode
json\encoder.py, ln 428, in _iterencode
json\encoder.py, ln 325, in _iterencode_list
json\encoder.py, ln 404, in _iterencode_dict
json\encoder.py, ln 325, in _iterencode_list
json\encoder.py, ln 404, in _iterencode_dict
json\encoder.py, ln 437, in _iterencode
Local\Temp\pip-unpacked-wheel-2lthyver\knack\output.py, ln 33, in default
json\encoder.py, ln 180, in default
TypeError: Object of type 'bytearray' is not JSON serializable

To Reproduce:

Expected Behavior

It to work

Environment Summary

Windows-10-10.0.17763-SP0
Python 3.6.8
Installer: MSI

azure-cli 2.15.1

Additional Context

yonzhan commented 4 years ago

az ad

jiasli commented 2 years ago

I can reproduce:

> az ad group member list -g 5e779b14-5559-4e1e-b9ca-0586bc8bb013 --debug
...
msrest.http_logger: Response content:
            ...
            "objectType": "ServicePrincipal",
            "appId": "bce1379e-91fc-4237-8be9-da8450b415f1",
            ...
            "passwordCredentials": [
                {
                    "customKeyIdentifier": "UGFzc3dvcmQhMjNl",

TypeError: Object of type bytearray is not JSON serializable

This issue is because commands like az ad group member list or az ad sp owner list don't have transform_graph_objects_with_cred transform which is applied to commands like az ad sp show or az ad sp credential list:

https://github.com/Azure/azure-cli/blob/487d00ea03741e245353dad8e26c4beab39fe176/src/azure-cli/azure/cli/command_modules/role/commands.py#L28

Of course we can fix this in AD Graph, but our main focus is now on Microsoft Graph (https://github.com/Azure/azure-cli/issues/12946). We won't set customKeyIdentifier after migrating to Microsoft Graph, but set displayName instead (https://github.com/Azure/azure-cli/issues/20561).

However, according to List members API's documentation:

https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http

Currently service principals are not listed as group members due to staged roll-out of service principals on Graph V1.0 endpoint. This operation is not transitive.

This seems like a feature gap between AD Graph and Microsoft Graph. We will internally work with Microsoft Graph team on this.

FlorentATo commented 8 months ago

Any update/status on this feature gap @jiasli ?