Skip to content

[Resource] Fix #34004: az resource wait: Raise CLIError on timeout instead of returning it - #34009

Open
Aditya Pujara (a0x1ab) wants to merge 1 commit into
Azure:devfrom
a0x1ab:agent-assist/azure-azure-cli-issue-34004-b92a89e7781c
Open

[Resource] Fix #34004: az resource wait: Raise CLIError on timeout instead of returning it#34009
Aditya Pujara (a0x1ab) wants to merge 1 commit into
Azure:devfrom
a0x1ab:agent-assist/azure-azure-cli-issue-34004-b92a89e7781c

Conversation

@a0x1ab

Copy link
Copy Markdown
Member

Description

Fixes #34004.

Related command
az resource wait (and all subcommands sharing WaitCommandOperation)

Description

WaitCommandOperation.wait was using return CLIError(...) on timeout instead of raise CLIError(...). The return value was silently discarded by callers, causing timed-out waits to exit with code 0 and no error output — indistinguishable from success.

  • command_operation.py: return CLIError(...)raise CLIError(...) at timeout path
  • test_wait_command_operation.py (new): unit tests asserting CLIError is raised on timeout and None is returned on success

Testing Guide

# Timeout path — previously exited 0 with no output, now raises CLIError
az resource wait --ids <resource-id> --custom "nonExistentProperty=='value'" --timeout 5
# Expected: CLIError: Wait operation timed-out after 5 seconds (exit code 1)

Unit tests added to src/azure-cli-core/azure/cli/core/tests/test_wait_command_operation.py.

History Notes

[Core] az resource wait: Fix timeout path to raise CLIError instead of silently returning it

…eout instead of returning it

* Initial plan

* fix: raise CLIError on wait timeout instead of returning it

Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>

* fix: raise CLIError on wait timeout; add unit tests

Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com>
@azure-client-tools-agent azure-client-tools-agent Bot added the Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review label Aug 29, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added Auto-Assign Auto assign by bot ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group act-identity-squad labels Aug 29, 2026
@azure-client-tools-agent
azure-client-tools-agent Bot marked this pull request as ready for review August 29, 2026 09:17
@azure-client-tools-agent
azure-client-tools-agent Bot requested a review from a team as a code owner August 29, 2026 09:17
Copilot AI lite review requested due to automatic review settings August 29, 2026 09:17
@azure-client-tools-agent
azure-client-tools-agent Bot requested review from a team as code owners August 29, 2026 09:17
@azure-pipelines

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

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

This PR fixes az resource wait timeout handling by raising a CLIError instead of returning a CLIError object that callers discard, ensuring timeouts fail with a non-zero exit code and an error message.

Changes:

  • Change WaitCommandOperation.wait timeout path from return CLIError(...) to raise CLIError(...).
  • Add unit tests verifying timeout raises CLIError and successful waits return None.

Reviewed changes

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

File Description
src/azure-cli-core/azure/cli/core/commands/command_operation.py Fixes timeout path to raise an error so az resource wait correctly fails on timeout.
src/azure-cli-core/azure/cli/core/tests/test_wait_command_operation.py Adds regression tests for timeout/error behavior and successful return behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -458,7 +458,7 @@ def wait(cls, command_args, cli_ctx, getter):
time.sleep(interval)
Comment on lines +36 to +37
with self.assertRaises(CLIError) as ctx:
WaitCommandOperation.wait(command_args, cli_ctx=cli_ctx, getter=getter)
@azure-client-tools-agent

Copy link
Copy Markdown
Contributor

Live test skipped

⏭️ Skipping the live test for this revision because the only test file(s) changed are azure-cli-core unit tests, which the live-test pipeline (azdev test --live) does not run — it covers command-module and extension tests only.

These azure-cli-core tests are exercised by upstream CI's unit-test jobs instead. This is informational; no action is required.

@yonzhan

Copy link
Copy Markdown
Collaborator

Resource

@azure-client-tools-agent azure-client-tools-agent Bot 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.

Aditya Pujara (@a0x1ab)

Automated Review Summary — PASS

CI: 19/19 completed checks passed, 0 failed. 3 checks
(Azure.azure-cli Breaking Change Test, Azure.azure-cli Full Test,
Azure.azure-cli) have been stuck in queued for ~198 minutes, well past the
180-minute abandoned threshold. A re-trigger attempt (rerun_stale_pr_checks)
returned 0 re-requested (cooldown or provider refusal), so these are treated
as zombie/abandoned checks rather than blocking failures. No completed check
has failed.

Live test: Skipped — the PR only changes
src/azure-cli-core/azure/cli/core/commands/command_operation.py and a new
unit test test_wait_command_operation.py; azure-cli-core unit tests are
not runnable via azdev test --live.

Regression coverage: Not applicable — the change is in azure-cli-core
infrastructure code, not a command module, so the module-coverage gap check
does not apply.

Review-skill findings: None. Reviewed against test-strength and
scope-consistency checks:

  • The change is a single-line fix (return CLIError(...)raise CLIError(...)) in WaitCommandOperation.wait, matching the PR title/issue
    scope exactly (az resource wait raising instead of returning on timeout).
  • The added unit test test_wait_command_operation.py asserts
    WaitCommandOperation.wait raises CLIError on timeout
    (test_wait_raises_on_timeout) and still returns None on the success path
    (test_wait_returns_none_on_success) — both assertions can fail if the
    implementation regresses, and the negative/timeout path is exercised.

Recommendation: No source changes requested. A maintainer may want to
manually re-run or inspect the 3 stuck Azure DevOps checks before merge, since
Azure Client Tools Agent could not re-trigger them, but nothing indicates a
PR-related failure.

@azure-client-tools-agent azure-client-tools-agent Bot added azure-client-tools-agent Pull request reviewed by Azure Client Tools Agent and removed Azure Client Tools Agent Requested Request Azure Client Tools Agent testing and review labels Aug 29, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

🔔 Routing this PR to @Azure/act-identity-squad.

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

Labels

act-identity-squad ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot azure-client-tools-agent Pull request reviewed by Azure Client Tools Agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az resource wait --custom returns exit code 0 when condition times out

4 participants