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

[Backup] Supplying non-existent name or natively formatted name for container causes stack trace #4502

Open
tjprescott opened this issue Sep 20, 2017 · 8 comments · Fixed by #5011
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Recovery Services Backup az backup RecoveryServices Service Attention This issue is responsible by Azure service team.

Comments

@tjprescott
Copy link
Member

Trying to run:
az backup protection backup-now -g tjp-ig -v vault1 --retain-until 01-01-2020 -c container1 -i item1

Yields:

'list' object has no attribute 'name'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/application.py", line 212, in execute
    result = expanded_arg.func(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 626, in _execute_command
    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 603, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 198, in backup_now
    container_type, item_type)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 145, in show_item
    items = list_items(client, resource_group_name, vault_name, container_name, container_type, item_type)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 159, in list_items
    return [item for item in paged_items if item.properties.container_name.lower() in container.name.lower()]
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 159, in <listcomp>
    return [item for item in paged_items if item.properties.container_name.lower() in container.name.lower()]
AttributeError: 'list' object has no attribute 'name'

In this case, it was not clear to me that a container and item had been created by the enable-for-vm command, so I assumed that these names were the names that would be created. When I realized it expected an existing name, I tried the container name obtained by running the backup container list command. However this yields the same stack trace. This AttributeError should be caught and handled gracefully. Additionally, it is perfectly fine to use a shorthand notation (like the VM name in this case) but:

  1. It should be clearly documented in help
  2. The parameter should definitely accept the format of name that the container object actually uses.

Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: WGET

CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here: azure-cli (2.0.17+dev)

acr (2.0.11+dev)
acs (2.0.15+dev)
appservice (0.1.16+dev)
backup (1.0.0+dev)
batch (3.1.3+dev)
billing (0.1.4+dev)
cdn (0.0.8+dev)
cloud (2.0.7+dev)
cognitiveservices (0.1.7+dev)
command-modules-nspkg (2.0.1+dev)
component (2.0.7+dev)
configure (2.0.10+dev)
consumption (0.1.4+dev)
container (0.1.10+dev)
core (2.0.16+dev)
cosmosdb (0.1.12+dev)
dla (0.0.11+dev)
dls (0.0.13+dev)
eventgrid (0.1.3+dev)
extension (0.0.2+dev)
feedback (2.0.6+dev)
find (0.2.6+dev)
interactive (0.3.9+dev)
iot (0.1.11+dev)
keyvault (2.0.10+dev)
lab (0.0.10+dev)
monitor (0.0.9+dev)
network (2.0.14+dev)
nspkg (3.0.1+dev)
profile (2.0.12+dev)
rdbms (0.0.6+dev)
redis (0.2.8+dev)
resource (2.0.14+dev)
role (2.0.11+dev)
servicefabric (0.0.3+dev)
sql (2.0.11+dev)
storage (2.0.15+dev)
vm (2.0.14+dev)

OS Version: What OS and version are you using?
Answer here: WSL

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here: Bash on Windows

@tjprescott tjprescott added bug This issue requires a change to an existing behavior in the product in order to be resolved. RecoveryServices labels Sep 20, 2017
@tjprescott tjprescott changed the title [Backup] Supplying non-existent container name causes stack trace [Backup] Supplying non-existent name or natively formatted name for container causes stack trace Sep 20, 2017
dragonfly91 pushed a commit to MabOneSdk/azure-cli that referenced this issue Nov 17, 2017
…tainer causes stack trace Azure#4502 Bug 1620939: Azure Backup CLI: Issue: Command output: Stack trace thrown instead of error"
@dragonfly91 dragonfly91 mentioned this issue Nov 23, 2017
3 tasks
dragonfly91 pushed a commit to MabOneSdk/azure-cli that referenced this issue Nov 30, 2017
…tainer causes stack trace Azure#4502 Bug 1620939: Azure Backup CLI: Issue: Command output: Stack trace thrown instead of error"
@dragonfly91 dragonfly91 mentioned this issue Nov 30, 2017
3 tasks
dragonfly91 pushed a commit to MabOneSdk/azure-cli that referenced this issue Jan 8, 2018
…tainer causes stack trace Azure#4502 Bug 1620939: Azure Backup CLI: Issue: Command output: Stack trace thrown instead of error"
tjprescott pushed a commit that referenced this issue Jan 9, 2018
* Fixes "Supplying non-existent name or natively formatted name for container causes stack trace #4502 Bug 1620939: Azure Backup CLI: Issue: Command output: Stack trace thrown instead of error"

* Work items done:
1. Bug: Check and fix if we are not passing custom request headers in some calls
2. Feature: Add health status in the table output for az backup item list command

* Pylint changes

* Updated history

* [backup] Updating test names for better tracking

* [backup] Fixing flake8 failures.

* [backup] Updating setup.py to match the top most version in history.

* [backup] Updating release notes to correctly identify the changes.
@tjprescott tjprescott reopened this Jan 9, 2018
@tjprescott
Copy link
Member Author

The was only partially fixed by PR #5011.

@nemo-xue
Copy link

Same error exists in azure-cli (2.0.29)

Trying to run:
az backup protection backup-now -g yg391 -v vaultName --container-name node0 --item-name node0 --retain-until 18-04-2018

Error message:
'list' object has no attribute 'name'
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 194, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 347, in execute
six.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 319, in execute
result = cmd(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 180, in call
return super(AzCliCommand, self).call(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/knack/commands.py", line 109, in call
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/init.py", line 418, in default_command_handler
result = op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 238, in backup_now
item_name, container_type, item_type)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 179, in show_item
items = list_items(cmd, client, resource_group_name, vault_name, container_name, container_type, item_type)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 197, in list_items
return [item for item in paged_items if item.properties.container_name.lower() in container.name.lower()]
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/backup/custom.py", line 197, in
return [item for item in paged_items if item.properties.container_name.lower() in container.name.lower()]
AttributeError: 'list' object has no attribute 'name'

Environment:
azure-cli (2.0.29)

acr (2.0.22)
acs (2.0.28)
advisor (0.5.0)
appservice (0.1.29)
backup (1.0.7)
batch (3.1.11)
batchai (0.1.6)
billing (0.1.7)
cdn (0.0.13)
cloud (2.0.12)
cognitiveservices (0.1.11)
command-modules-nspkg (2.0.1)
configure (2.0.14)
consumption (0.2.2)
container (0.1.19)
core (2.0.29)
cosmosdb (0.1.19)
dla (0.0.18)
dls (0.0.19)
eventgrid (0.1.11)
eventhubs (0.1.0)
extension (0.0.10)
feedback (2.1.0)
find (0.2.8)
interactive (0.3.17)
iot (0.1.18)
keyvault (2.0.20)
lab (0.0.17)
monitor (0.1.3)
network (2.0.25)
nspkg (3.0.2)
profile (2.0.20)
rdbms (0.1.0)
redis (0.2.11)
reservations (0.1.1)
resource (2.0.25)
role (2.0.20)
servicebus (0.1.0)
servicefabric (0.0.11)
sql (2.0.23)
storage (2.0.27)
vm (2.0.28)

Python location '/opt/az/bin/python3'
Extensions directory '/home/yg/.azure/cliextensions'

Python (Linux) 3.6.1 (default, Mar 10 2018, 01:18:09)
[GCC 5.4.0 20160609]

I'm running it on azure cloud shell.

@andrewdobbie
Copy link

I think the CLI is breaking because of the Azure REST API.
https://management.azure.com/Subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/${vaultName}/backupProtectionContainers?api-version=2017-07-01&$filter=backupManagementType eq 'AzureIaasVM' and status eq 'Registered' and friendlyName eq 'myVM'
When I call backupProtectionContainers API as above, I get a list instead of the single expected container. It's returning containers from multiple resource groups in the subscription where the containers have the same friendlyName. The CLI will always break when the REST API does not filter using resourceGroupName and vaultName.

@dragonfly91
Copy link

dragonfly91 commented Mar 23, 2018

@yg-xue can you please try with the latest version of backup (1.1.0)?

@nemo-xue
Copy link

@dragonfly91
How to get backup (1.1.0) installed?
I tried to do edge build, but the backup component is still 1.0.7.
Command I used for edge build:
$ pip install --upgrade --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge --no-cache-dir

@dragonfly91
Copy link

Looks like the change is not yet released. Please follow https://github.com/Azure/azure-cli/milestone/36 for the dates

@nemo-xue
Copy link

nemo-xue commented Mar 26, 2018 via email

@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Jun 14, 2019
@pvrk
Copy link
Member

pvrk commented Jul 29, 2019

@siddharth7 : can you please check if the bug is fixed in the latest release?

@haroldrandom haroldrandom added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Oct 25, 2019
@haroldrandom haroldrandom added Recovery Services Backup az backup RecoveryServices Service Attention This issue is responsible by Azure service team. labels Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Recovery Services Backup az backup RecoveryServices Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants