Skip to content

Fix ValueError in az serial-console connect when boot diagnostics storage account is inaccessible#33453

Draft
Copilot wants to merge 2 commits into
devfrom
copilot/fix-serial-console-value-error
Draft

Fix ValueError in az serial-console connect when boot diagnostics storage account is inaccessible#33453
Copilot wants to merge 2 commits into
devfrom
copilot/fix-serial-console-value-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

Related command
az serial-console connect

Description

az serial-console connect crashes with ValueError: No value for given attribute when a VM has boot diagnostics configured with an explicit storage account URL that is not accessible in the current subscription (e.g., deleted or cross-subscription).

Root cause: get_storage_account_info() in custom.py guarded with if storage_account is not None before calling scf.storage_accounts.get_properties(storage_account_resource_group, storage_account), but storage_account_resource_group can also be None when resource_group_from_storage_account_name() cannot find the account in the subscription. Passing None as resource_group_name to azure-mgmt-storage's serializer raises the ValueError.

Fix: Added and storage_account_resource_group is not None to the guard. When the resource group is undiscoverable, get_properties() is skipped and None is returned — the command proceeds without region-specific routing, matching the managed-storage behavior.

# Before
if storage_account is not None:
    sa_result = scf.storage_accounts.get_properties(storage_account_resource_group, storage_account)

# After
if storage_account is not None and storage_account_resource_group is not None:
    sa_result = scf.storage_accounts.get_properties(storage_account_resource_group, storage_account)

Changes:

  • src/serial-console/azext_serialconsole/custom.py — one-line guard fix in get_storage_account_info()
  • src/serial-console/azext_serialconsole/tests/latest/test_custom_unit.py — new mock-based unit tests covering all get_storage_account_info and parse_storage_account_url code paths, including the regression case
  • src/serial-console/HISTORY.rst / setup.py — version bumped to 1.0.0b4

Testing Guide

Run the new unit tests (no live Azure resources required):

PYTHONPATH=src/serial-console python -m pytest src/serial-console/azext_serialconsole/tests/latest/test_custom_unit.py -v

History Notes

[serial-console] az serial-console connect: Fix ValueError: No value for given attribute crash when the VM's boot diagnostics storage account is not accessible in the current subscription.


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented May 28, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented May 28, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

…urce group is None

When a VM has boot diagnostics configured with an explicit storage account URL,
but that storage account is not accessible in the current subscription (e.g., it
was deleted or is in a different subscription), resource_group_from_storage_account_name()
returns None. The previous code only checked `storage_account is not None` before
calling get_properties(), allowing None to be passed as resource_group_name,
which caused azure-mgmt-storage to raise ValueError: No value for given attribute.

Fix: add `storage_account_resource_group is not None` guard so that when the
resource group cannot be determined, get_properties() is skipped and None is
returned gracefully (the serial-console command continues without region-specific
routing).
Copilot AI changed the title [WIP] Fix ValueError in az serial-console connect command Fix ValueError in az serial-console connect when boot diagnostics storage account is inaccessible May 28, 2026
Copilot finished work on behalf of a0x1ab May 28, 2026 06:30
Copilot AI requested a review from a0x1ab May 28, 2026 06:30
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 28, 2026

serial-console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az serial-console connect results in python error ValueError: No value for given attribute

3 participants