Skip to content

sys.exit(3) prevents me from handling exception #30895

@robbelouwet

Description

@robbelouwet

Describe the bug

Sys.exit(3) is called when a resource is not found, and since azure-cli is also a python pip package that can be used as an API in python programs, I can't handle this exception myself because the program just exits. I would recommend not doing the sys.exit(3) and allowing exception handling.

Related command

az container show

Errors

ERROR:cli.azure.cli.core.azclierror:(ResourceNotFound) The Resource 'Microsoft.ContainerInstance/containerGroups/xxxxxxxx' under resource group 'xxxxxx' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound

Issue script & Debug output

ERROR:cli.azure.cli.core.azclierror:(ResourceNotFound) The Resource 'Microsoft.ContainerInstance/containerGroups/xxxxxxxx' under resource group 'xxxxxx' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound

The arm requests are not logged even in --debug mode, Maybe this is because of the systemexit()? I get the non-debug output as shown above, but no ARM requests. I'm sure about this because my program executes other az cli commands that all show ARM requests being logged, except for this call to az container show.

Expected behavior

Raising an exception

Environment Summary

azure-cli 2.67.0
azure-cli-core 2.67.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignAuto assign by botAuto-ResolveAuto resolve by botContainer Instancesaz containerService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions