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

az lock create|delete --resource <rg-id> fails with cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip' #18862

Closed
hayorov opened this issue Jul 14, 2021 · 5 comments
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Customer Usage

Comments

@hayorov
Copy link

hayorov commented Jul 14, 2021

Describe the bug

az lock create or delete fails with error code = 2 with parameter --resource=/subscriptions/XXX/resourceGroups/YYY

Command Name
az lock create --name <name> --resource /subscriptions/XXX/resourceGroups/YYY
`az lock delete --name --resource /subscriptions/XXX/resourceGroups/YYY``

Errors:

cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f7731872620>]
az_command_data_logger: exit code: 2

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • az lock delete --name {} --resource /subscriptions/XXX/resourceGroups/YYY --debug

Expected Behavior

resource lock created or deleted respectively.

Environment Summary

Linux-4.15.0-1098-azure-x86_64-with-debian-9.13
Python 3.6.10
Installer: DEB

azure-cli 2.21.0

Additional Context

cli.knack.cli: Command arguments: ['lock', 'delete', '--name', 'resourceGroupLockV2', '--resource', '/subscriptions/XXX/resourceGroups/YYY', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f77328ed950>, <function OutputProducer.on_global_arguments at 0x7f77321b7730>, <function CLIQuery.on_global_arguments at 0x7f77321d69d8>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'lock': ['azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: resource                  0.012        36       171
cli.azure.cli.core: Total (1)                 0.012        36       171
cli.azure.cli.core: Loaded 36 groups, 171 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : lock delete
cli.azure.cli.core: Command table: lock delete
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f7731872400>]
az_command_data_logger: command args: lock delete --name {} --resource {} --debug
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/builder/.azure/commands'.
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f77318a0378>, <function register_global_query_examples_argument.<locals>.register_query_examples at 0x7f77317fea60>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f77317feae8>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f77317febf8>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f77321b77b8>, <function CLIQuery.handle_query_parameter at 0x7f77321d6a60>, <function register_global_query_examples_argument.<locals>.handle_example_parameter at 0x7f77317fe9d8>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f77317feb70>]
cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f7731872620>]
az_command_data_logger: exit code: 2

Command with --resource-name <rg-name> works as expected.

@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jul 14, 2021
@yonzhan yonzhan added the ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group label Jul 14, 2021
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Jul 14, 2021
@yonzhan yonzhan added Service Attention This issue is responsible by Azure service team. and removed customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jul 14, 2021
@ghost
Copy link

ghost commented Jul 14, 2021

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure.

Issue Details

Describe the bug

az lock create or delete fails with error code = 2 with parameter --resource=/subscriptions/XXX/resourceGroups/YYY

Command Name
az lock create --name <name> --resource /subscriptions/XXX/resourceGroups/YYY
`az lock delete --name --resource /subscriptions/XXX/resourceGroups/YYY``

Errors:

cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f7731872620>]
az_command_data_logger: exit code: 2

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • az lock delete --name {} --resource /subscriptions/XXX/resourceGroups/YYY --debug

Expected Behavior

resource lock created or deleted respectively.

Environment Summary

Linux-4.15.0-1098-azure-x86_64-with-debian-9.13
Python 3.6.10
Installer: DEB

azure-cli 2.21.0

Additional Context

cli.knack.cli: Command arguments: ['lock', 'delete', '--name', 'resourceGroupLockV2', '--resource', '/subscriptions/XXX/resourceGroups/YYY', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f77328ed950>, <function OutputProducer.on_global_arguments at 0x7f77321b7730>, <function CLIQuery.on_global_arguments at 0x7f77321d69d8>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'lock': ['azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: resource                  0.012        36       171
cli.azure.cli.core: Total (1)                 0.012        36       171
cli.azure.cli.core: Loaded 36 groups, 171 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : lock delete
cli.azure.cli.core: Command table: lock delete
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f7731872400>]
az_command_data_logger: command args: lock delete --name {} --resource {} --debug
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/builder/.azure/commands'.
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f77318a0378>, <function register_global_query_examples_argument.<locals>.register_query_examples at 0x7f77317fea60>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f77317feae8>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f77317febf8>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f77321b77b8>, <function CLIQuery.handle_query_parameter at 0x7f77321d6a60>, <function register_global_query_examples_argument.<locals>.handle_example_parameter at 0x7f77317fe9d8>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f77317feb70>]
cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip'
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f7731872620>]
az_command_data_logger: exit code: 2

Command with --resource-name <rg-name> works as expected.

Author: hayorov
Assignees: -
Labels:

ARM, Service Attention

Milestone: -

@yonzhan
Copy link
Collaborator

yonzhan commented Jul 14, 2021

route to service team

@zhoxing-ms zhoxing-ms added Customer Usage and removed Service Attention This issue is responsible by Azure service team. labels Jul 15, 2021
@zhoxing-ms
Copy link
Contributor

# az lock create -h

    --resource --resource-name : Name or ID of the resource being locked. If an ID is given, other
                                 resource arguments should not be given.
    --resource-group -g        : Name of resource group. You can configure the default group using
                                 `az configure --defaults group=<name>`.

@hayorov Hi, in fact, the parameter --resource is used to pass in resource ID. If you need to operate resource group, you should pass in parameter --resource-group.
Such as az lock create -n lock_name -t CanNotDelete -g resource_group_name, please have a try~

@yonzhan yonzhan closed this as completed Jul 15, 2021
@hayorov
Copy link
Author

hayorov commented Jul 15, 2021

@zhoxing-ms
A resource group is a resource, it has its own id - /subscription/XXX/resourcegroups/YYY.
(1) I don't see any reasonable argument why --resource cannot be used to lock the resource group or any other resource by using universal id. Even the description says - If an ID is given, other resource arguments should not be given. like -g
(2) Also, this limitation az cli limitation is totally unclear from the description/help and should be at least mentioned.
(3) Finally, the error itself cli.azure.cli.core.azclierror: 'NoneType' object has no attribute 'strip' is unclear and should be improved

@yonzhan

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Jul 15, 2021

@hayorov In fact, in CLI, the group name/id cannot be passed into --resource-name/--resource in all commands, and we always use different parameters --resource-name and --resource-group to distinguish them. This is because resource and resource group belong to different levels, so the processing logic behind them and the corresponding REST service are different. (Moreover, the commands to operate resource and resource group are completely independent: az resource and az group)
Thank you for your suggestion. We will consider improving the help information and add some examples to tell users the difference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Customer Usage
Projects
None yet
Development

No branches or pull requests

3 participants