Skip to content

containerapp revision label add fails with unhelpful error when label already exists #32901

@ascott18

Description

@ascott18

Describe the bug

containerapp revision label add fails in CI with a python stack trace if the revision already exists, instead of a useful error message. It appears that its trying to prompt for confirmation based on "NoTTYException". This should be fixed to display a helpful error message instead of a stack dump. E.g. "A label with name already exists. Pass --no-prompt to remove label from and add it to ".

Related command

az containerapp revision label add --name $appName
--resource-group $resourceGroup --label live
--revision $nextRevision

Errors

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 
Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/command_modules/containerapp/custom.py", line 2280, in add_revision_label
    if not prompt_y_n(msg, default="n"):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/knack/prompting.py", line 71, in prompt_y_n
    return _prompt_bool(msg, 'y', 'n', default=default, help_string=help_string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/knack/prompting.py", line 79, in _prompt_bool
    verify_is_a_tty()
  File "/opt/az/lib/python3.12/site-packages/knack/prompting.py", line 28, in verify_is_a_tty
    raise NoTTYException()
knack.prompting.NoTTYException
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

Issue is self-evident from stack trace. Not an issue with AzureRM calls. Way to much private information in the debug for me to share.

Expected behavior

Command provides useful error message when there's no TTY instead of crashing.

Environment Summary

==============================================================================
Task         : Azure CLI
Description  : Run Azure CLI commands against an Azure subscription in a PowerShell Core/Shell script when running on Linux agent or PowerShell/PowerShell Core/Batch script when running on Windows agent.
Version      : 2.270.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
==============================================================================
/usr/bin/az version
{
  "azure-cli": "2.74.0",
  "azure-cli-core": "2.74.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignAuto assign by botAuto-ResolveAuto resolve by botContainerAppError MessagesService 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