Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

Azure Devops pipeline fails intermittently when trying to create a new variable in variable group using "az pipelines variable-group variable create" #29803

Open ajaind86 opened 2 weeks ago

ajaind86 commented 2 weeks ago

Describe the bug

One of the tasks in our pipeline is to create a new variable in a variable group

- script: |
                az extension add --name azure-devops --allow-preview false
                az pipelines variable-group variable create --group-id 481 --org "https://dev.azure.com/dwc/" --project "Test" --name $(tag) --value $(outputId)
            displayName: "Save output id to variable"
            env:
              AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)

The task fails with the following error

Related command

az extension add --name azure-devops --allow-preview false
az pipelines variable-group variable create 

Errors

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 'NoneType' object has no attribute 'keys'
Traceback (most recent call last):
  File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 723, in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 31, in azure_devops_exception_handler
    reraise(*sys.exc_info())
  File "/opt/az/lib/python3.11/site-packages/six.py", line 719, in reraise
    raise value
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/root/.azure/cliextensions/azure-devops/azext_devops/dev/pipelines/variable_group.py", line 182, in variable_group_variable_add
    for key in var_group.variables.keys():
               ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'keys'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 'NoneType' object has no attribute 'keys'
Traceback (most recent call last):
  File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
    raise ex
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 723, in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 31, in azure_devops_exception_handler
    reraise(*sys.exc_info())
  File "/opt/az/lib/python3.11/site-packages/six.py", line 719, in reraise
    raise value
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/root/.azure/cliextensions/azure-devops/azext_devops/dev/pipelines/variable_group.py", line 182, in variable_group_variable_add
    for key in var_group.variables.keys():
               ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'keys'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Expected behavior

Should not fail

Environment Summary

N/A

Additional context

No response

yonzhan commented 2 weeks ago

Thank you for opening this issue, we will look into it.

microsoft-github-policy-service[bot] commented 2 weeks ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @v-anvashist, @V-hmusukula.