Skip to content

[Container App Job] Fix crash for containerapp job update --no-wait - #33807

Open
cimnine wants to merge 2 commits into
Azure:devfrom
nxt-engineering:containerapp-job-update-nowait
Open

[Container App Job] Fix crash for containerapp job update --no-wait#33807
cimnine wants to merge 2 commits into
Azure:devfrom
nxt-engineering:containerapp-job-update-nowait

Conversation

@cimnine

@cimnine cimnine commented Jul 28, 2026

Copy link
Copy Markdown

Related command

az containerapp job update \
            --name ${{ job.Name }} \
            --resource-group ${{ parameters.ResourceGroupName }} \
            --image ${{ parameters.ContainerRegistryName }}/${{ job.Repository }}:${{ parameters.ImageTag }} \
            --no-wait

Description
It fixes the following crash:

2026-07-28T12:18:42.1518490Z ##[section]Starting: containerappjob:update caj-csx-t-zh-1-cleanup-files
2026-07-28T12:18:42.1523350Z ==============================================================================
2026-07-28T12:18:42.1523463Z Task         : Bash
2026-07-28T12:18:42.1523517Z Description  : Run a Bash script on macOS, Linux, or Windows
2026-07-28T12:18:42.1523601Z Version      : 3.274.1
2026-07-28T12:18:42.1523659Z Author       : Microsoft Corporation
2026-07-28T12:18:42.1523725Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2026-07-28T12:18:42.1523822Z ==============================================================================
2026-07-28T12:18:42.2436757Z Generating script.
2026-07-28T12:18:42.2446049Z ========================== Starting Command Output ===========================
2026-07-28T12:18:42.2453901Z [command]/usr/bin/bash /azp/_temp/6c0482c6-5b76-4f4c-9990-d90ee6a19cef.sh
2026-07-28T12:18:45.7184805Z ERROR: The command failed with an unexpected error. Here is the traceback:
2026-07-28T12:18:45.7212321Z ERROR: argument of type 'NoneType' is not iterable
2026-07-28T12:18:45.7212652Z Traceback (most recent call last):
2026-07-28T12:18:45.7212911Z   File "/opt/az/lib/python3.13/site-packages/knack/cli.py", line 233, in invoke
2026-07-28T12:18:45.7213156Z     cmd_result = self.invocation.execute(args)
2026-07-28T12:18:45.7213422Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
2026-07-28T12:18:45.7213669Z     raise ex
2026-07-28T12:18:45.7213939Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
2026-07-28T12:18:45.7214241Z     results.append(self._run_job(expanded_arg, cmd_copy))
2026-07-28T12:18:45.7214471Z                    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
2026-07-28T12:18:45.7214735Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
2026-07-28T12:18:45.7215001Z     return cmd_copy.exception_handler(ex)
2026-07-28T12:18:45.7215225Z            ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
2026-07-28T12:18:45.7215722Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/_client_factory.py", line 28, in _polish_bad_errors
2026-07-28T12:18:45.7216001Z     raise ex
2026-07-28T12:18:45.7216241Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
2026-07-28T12:18:45.7216492Z     result = cmd_copy(params)
2026-07-28T12:18:45.7216742Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
2026-07-28T12:18:45.7217025Z     return self.handler(*args, **kwargs)
2026-07-28T12:18:45.7217243Z            ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
2026-07-28T12:18:45.7217519Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
2026-07-28T12:18:45.7217819Z     return op(**command_args)
2026-07-28T12:18:45.7218076Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/custom.py", line 1084, in update_containerappsjob
2026-07-28T12:18:45.7218294Z     return update_containerappsjob_logic(cmd=cmd,
2026-07-28T12:18:45.7218447Z                                          name=name,
2026-07-28T12:18:45.7218695Z     ...<25 lines>...
2026-07-28T12:18:45.7218934Z                                          max_executions=max_executions,
2026-07-28T12:18:45.7219156Z                                          no_wait=no_wait)
2026-07-28T12:18:45.7219452Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/custom.py", line 1449, in update_containerappsjob_logic
2026-07-28T12:18:45.7219765Z     handle_raw_exception(e)
2026-07-28T12:18:45.7219987Z     ~~~~~~~~~~~~~~~~~~~~^^^
2026-07-28T12:18:45.7220297Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/_client_factory.py", line 63, in handle_raw_exception
2026-07-28T12:18:45.7220826Z     raise e
2026-07-28T12:18:45.7221140Z   File "/opt/az/lib/python3.13/site-packages/azure/cli/command_modules/containerapp/custom.py", line 1444, in update_containerappsjob_logic
2026-07-28T12:18:45.7221703Z     if "properties" in r and "provisioningState" in r["properties"] and r["properties"]["provisioningState"].lower() == "waiting" and not no_wait:
2026-07-28T12:18:45.7222000Z        ^^^^^^^^^^^^^^^^^
2026-07-28T12:18:45.7222227Z TypeError: argument of type 'NoneType' is not iterable
2026-07-28T12:18:45.7237609Z To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
2026-07-28T12:18:45.8265973Z 
2026-07-28T12:18:45.8303855Z ##[error]Bash exited with code '1'.
2026-07-28T12:18:45.8337872Z ##[section]Finishing: containerappjob:update caj-csx-t-zh-1-cleanup-files

This patch was created with the help of Claude Code:

This confirms the fix is exactly what az containerapp update (the non-job command) already does — the two are structurally identical, and the job version was the outlier.

ContainerAppClient.update (_clients.py:159-160) and ContainerAppsJobClient.update (_clients.py:895-896) both do the same thing: return None when no_wait=True.

 if no_wait:
     return

update_containerapp_logic (regular containerapp update), custom.py:710-715:

 r = ContainerAppClient.update(
     cmd=cmd, resource_group_name=resource_group_name, name=name, container_app_envelope=new_containerapp, no_wait=no_wait)

 if not no_wait and "properties" in r and "provisioningState" in r["properties"] and r["properties"]["provisioningState"].lower() == "waiting":

not no_wait is checked first, so when no_wait=True and r is None, the and chain short-circuits before ever touching r["properties"]. Safe.

update_containerappsjob_logic (containerapp job update), custom.py:1442-1446before my fix:

r = ContainerAppsJobClient.update(
    cmd=cmd, resource_group_name=resource_group_name, name=name, containerapp_job_envelope=new_containerappsjob, no_wait=no_wait)

if "properties" in r and "provisioningState" in r["properties"] and r["properties"]["provisioningState"].lower() == "waiting" and not no_wait:

Same None-on-no_wait return, but not no_wait was placed last. With no_wait=True, Python still evaluates "properties" in r on r = None before ever reaching not no_wait — hence TypeError: argument of type 'NoneType' is not iterable, exactly matching the pipeline traceback.

My fix moves not no_wait to the front, at line 1446, making the job command's check byte-for-byte identical in structure to the container-app command's (and to the two other matching sites at custom.py:249 and custom.py:1527). All four now read:

if not no_wait and "properties" in r and "provisioningState" in r["properties"] and r["properties"]["provisioningState"].lower() == "waiting":

So the job path now behaves the same as the already-correct app path under --no-wait.

Testing Guide

This will not crash anymore:

az containerapp job update \
            --name ${{ job.Name }} \
            --resource-group ${{ parameters.ResourceGroupName }} \
            --image ${{ parameters.ContainerRegistryName }}/${{ job.Repository }}:${{ parameters.ImageTag }} \
            --no-wait

History Notes


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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@cimnine
cimnine marked this pull request as ready for review July 28, 2026 13:24
@cimnine
cimnine requested review from a team, Greedygre, Juliehzl and howang-ms as code owners July 28, 2026 13:24
Copilot AI review requested due to automatic review settings July 28, 2026 13:24
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@cimnine

cimnine commented Jul 28, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="nxt Engineering GmbH"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a TypeError: argument of type 'NoneType' is not iterable crash in az containerapp job update --no-wait by ensuring the provisioning-state warning check short-circuits before evaluating the response object when no_wait=True.

Changes:

  • Reorders the post-update provisioningState == "waiting" check in update_containerappsjob_logic to guard on not no_wait first.
  • Adds unit tests to ensure both containerapp update and containerapp job update do not crash under --no-wait and still return the update response when no_wait=False.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/azure-cli/azure/cli/command_modules/containerapp/custom.py Prevents None response from being evaluated in the provisioning-state check when --no-wait is set.
src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_update_provisioning_state.py Adds regression tests covering no_wait=True (no crash) and no_wait=False (returns response) for both app and job update paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants