Repository navigation
[Core] Fix #34150: az: Support tempfile-backed Git Bash completion - #34248
Aditya Pujara (a0x1ab) wants to merge 1 commit into
Conversation
X Engineering Agent ReportReview — Comments Independent reviewAddressed in this revision: Packaged shell tests now locate No confirmed semantic defects found at Upstream CI: 52/52 passed, per the supplied snapshot. Agent live-test evidence is reported separately below. Windows 11 MSI/Git Bash artifact execution was not independently verified; the added MSI harness ( Test validation
Risk assessment — 0/100 · LowThe Low rating reflects the detected change scope with no elevated security, reliability, customer, operational, dependency, sovereign-cloud, generated-output, or cross-component signal.
Posted by x-engineering-agent (Reviewer) Live test — Passed (3/3)PASS Selectors: Changed test files runNew test filesWorkflow run: https://github.com/Azure/issue-sentinel/actions/runs/40166125839 Last 80 lines of azdev outputPosted by x-engineering-agent (Tester) |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
🔵 Needs a closer look
Windows 11 MSI/Git Bash validation still requires maintainer confirmation, and the packaged-test setup issue remains unresolved.
1 open issue
What changed in this PR
Adds opt-in tempfile-backed Bash completion for Azure CLI to address Git Bash’s limitations with native Windows file descriptors.
Changes:
- Honors
ARGCOMPLETE_USE_TEMPFILES=1, with tempfile cleanup and failure handling. - Preserves the default descriptor transport and completion spacing behavior.
- Adds shell-level tests for both transports, failures, and installed-CLI completion.
| File | Description |
|---|---|
src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py |
Adds completion transport and regression tests. |
az.completion |
Adds opt-in tempfile transport for completion results. |
Review effort: Balanced
| if not platform.startswith('MINGW'): | ||
| self.skipTest('Windows completion tests require Git Bash') | ||
| self.completion = Path(__file__).resolve().parents[6] / 'az.completion' | ||
| self.assertTrue(self.completion.is_file()) |
|
@Azure/act-observability-squad LGTM, can we get your review? |
2811d00 to
e709fb5
Compare
|
@x-engineering-agent please resolve the open P2 test resource finding. Make |
…tion Root cause: The original PR's ArgcompleteShellTest.setUp in src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py and CompletionTest._complete in src/azure-cli/azure/cli/command_modules/util/tests/latest/test_completion.py used fixed checkout-relative parent indices and asserted az.completion existed. scripts/ci/build.sh packages those tests into azure-cli-fulltest without copying the repository-root shell resource. Installed tests therefore failed before exercising completion. This revision retains the restored candidate's layout-independent resource search and explicit missing-resource skip, and strengthens its regression evidence. Change: Preserved the restored candidate's search through resolved test-file ancestors and the current checkout directory in both completion suites. When no regular az.completion file is found, tests explicitly skip with 'az.completion is not available in the test installation or checkout'. Preserved installed-resource, adjacent-resource, and checkout-CWD regressions; added checkout-backed test-path coverage from an unrelated working directory and directory-not-file skip coverage to both resource unit suites. No packaging, production completion, launcher, MSI validation, generated code, or recording changes. … Origin: The checkout-only lookups are present in PR 34248 head e709fb5. They intended to source the actual repository shell script. The resource fix keeps that intention in checkout CI and MSI validation while explicitly handling installations that do not ship that resource. Why now: The human review identifies the azure-cli-fulltest packaging layout, which scripts/ci/build.sh:82-98 and 137-147 constructs without the root completion script. Checkout-backed runs already pass and thus did not expose the fixed-parent resource assumptions. Blast radius: Test-only change. No CLI command behavior or shared runtime helper changes. The existing core completion assertions cover account, vm, network, storage and --output; the real-CLI util scenarios remain unchanged. No unrelated core or util runtime source is touched. Alternatives considered: - Bundle duplicate copies of az.completion into the fulltest artifact: not necessary because the reviewer explicitly permits skipping when unavailable, and duplicate shell resources would require additional packaging and synchronization changes. - Always skip installed completion tests: rejected because available installed resources and checkout-backed installed tests must still execute. Verified: - Trusted validation passed (1 command). - New or changed tests fail on the base revision and pass with the change: `src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_cli_failure_recovery`, `src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_tempfile_cleanup_failure`, `src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_tempfile_creation_failure`. - Unit tests: 25 executed, 0 skipped. - Recorded scenario tests replayed offline: 4 executed. - PSScriptAnalyzer passed. - Pre-publication gates passed: release-artifact, generated-ownership, command-help, suppression, independent-review. - Repository CI and live tests run on this PR.
e709fb5 to
52ebc9e
Compare
There was a problem hiding this comment.
Aditya Pujara (@a0x1ab) Ready for human review. See the X Engineering Agent Report.

🤖 PR Validation —⚠️ Review suggested
This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.
src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.pyself.skipTest('Bash is not installed')src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.pyself.skipTest('Windows completion tests require Git Bash')src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.pyself.skipTest('az.completion is not available in the test installation or checkout')src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.pyself.skipTest('Azure CLI is not installed')src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.pyself.skipTest('Azure CLI is not installed')src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.pyself.skipTest('Azure CLI is not installed')src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.pyself.skipTest('Azure CLI is not installed')src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell_resource_unit.pyself.skipTest('Bash is not installed')src/azure-cli/azure/cli/command_modules/util/tests/latest/test_completion.pyself.skipTest('Bash is not installed')src/azure-cli/azure/cli/command_modules/util/tests/latest/test_completion.pyself.skipTest('Azure CLI is not installed')src/azure-cli/azure/cli/command_modules/util/tests/latest/test_completion.pyself.skipTest('az.completion is not available in the test installation or checkout')src/azure-cli/azure/cli/command_modules/util/tests/test_completion_resource_unit.pyself.skipTest('Bash is not installed')src/azure-cli/azure/cli/command_modules/util/tests/test_completion_resource_unit.pyself.skipTest('Azure CLI is not installed')Related command
az ...Description
Fixes #34150.
az: Support tempfile-backed Git Bash completion.Low confidence, do not merge yet: the sandbox could not verify: On Windows 11 in Git Bash (MINGW64), with Azure CLI installed via the Windows MSI, sourcing the supplied az.completion script and exporting ARGCOMPLETE_USE_TEMPFILES=1 makes Tab …; Completion works in that environment without replacing the completion function in .bashrc.. It stays a draft with the
do-not-mergelabel until a maintainer verifies the root cause and the fix.Root cause: az.completion: _az_python_argcomplete originally always used descriptors 8/9 and never passed _ARGCOMPLETE_STDOUT_FILENAME, although AzCompletionFinder inherits argcomplete's file-output support. Native MSI CLI processes under Git Bash cannot reliably receive those descriptors. The existing PR correctly adds opt-in tempfile transport, but its new mktemp, cat and rm calls leave stderr connected to the terminal. Genuine helper failures therefore print diagnostics during completion. The prior silent mktemp test stub did not expose that error-output defect.
Fix: Preserved the existing opt-in tempfile fix, default descriptor transport and upstream completion registration. Added 2>/dev/null only to mktemp, cat and rm, retaining their error statuses, cleanup attempts and candidate clearing. Added a real helper creation-failure/recovery LiveScenarioTest first, replaced the silent unit creation stub with a missing TMPDIR, and added actual read/removal failure cases. Unlike earlier attempts, this change addresses the concrete helper diagnostic leak rather than claiming additional Linux tests prove Windows success.
Origin: commit: 1271aa0; pull_request: #1808; date: 2017-01-23; intent: PR #1808, Packaged release 0.1.7 for Debian & Docker, added packaged_releases/az.completion to the packaged release archive. Its added-file patch contains the descriptor-only wrapper and no tempfile transport. The fix preserves that completion and packaging intent.; trace: Verified through public GitHub commit history and …
Why now: Verified history shows the missing tempfile transport predates the current issue; no recent dependency or service regression is established. The reported Windows MSI/Git Bash descriptor boundary makes that longstanding gap visible, and default/bashdefault fallback added by PR #11817 explains why missing CLI candidates appear as filesystem suggestions. The refreshed review …
Blast radius: Only the handwritten shared Bash wrapper changes; no core Python parser or command implementation changes. All az completions opting into ARGCOMPLETE_USE_TEMPFILES=1 suppress helper stderr while retaining failure status and empty candidates; default descriptor users are unchanged. Real CLI/Readline scenarios cover account, vm, network and storage top-level suggestions, account set/show, --output, …
Risks and limitations (from the job report):
Testing Guide
History Notes
Generated from the pull request title.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.