Repository navigation
[Core] Fix #34150: az: Support tempfile-backed Git Bash completion - #34248
Draft
Aditya Pujara (a0x1ab) wants to merge 1 commit into
Draft
Aditya Pujara (a0x1ab) wants to merge 1 commit into
Aditya Pujara (a0x1ab) wants to merge 1 commit into
Conversation
…tion Root cause: az.completion: _az_python_argcomplete always captured completion output through descriptors 8 and 9 and never created or passed _ARGCOMPLETE_STDOUT_FILENAME. Azure CLI's AzCompletionFinder inherits argcomplete's existing file-output support, but the shell wrapper ignored ARGCOMPLETE_USE_TEMPFILES=1. Native Windows CLI programs launched by Git Bash cannot reliably use the descriptor transport. Change: Added an opt-in tempfile transport to handwritten root az.completion. For ARGCOMPLETE_USE_TEMPFILES=1 it creates a secure tempfile, passes _ARGCOMPLETE_STDOUT_FILENAME to az, reads successful candidates into COMPREPLY, removes the file on success or command failure, and clears previous/partial candidates while propagating failures. The existing descriptor invocation and nospace behavior are preserved when the flag is unset. Added focused shell-level unit tests sourcing the actual script, including an offline file-only Windows backend model and an installed-CLI scenario that … Alternatives considered: - Changing the Python backend was rejected because argcomplete already supports _ARGCOMPLETE_STDOUT_FILENAME. - Replacing the default descriptor transport with tempfiles was rejected to preserve existing completion setups. 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_tempfile_creation_failure`, `src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_tempfile_current_line`, `src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_tempfile_failure`. - Unit tests: 7 executed, 0 skipped. - Pre-publication gates passed: release-artifact, generated-ownership, command-help, lint, regression-test, independent-review. - Repository CI and live tests run on this PR. Fixes Azure#34150
Contributor
X Engineering Agent ReportLive test — SkippedSkipping the live test for this revision because the only test file(s) changed are These Posted by x-engineering-agent (Tester) |
microsoft-github-policy-service
Bot
requested a review
from Yong Zhang (yonzhan)
October 20, 2026 15:10
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Validation — ️✔️ All clear
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 always captured completion output through descriptors 8 and 9 and never created or passed _ARGCOMPLETE_STDOUT_FILENAME. Azure CLI's AzCompletionFinder inherits argcomplete's existing file-output support, but the shell wrapper ignored ARGCOMPLETE_USE_TEMPFILES=1. Native Windows CLI programs launched by Git Bash cannot reliably use the descriptor transport.
Fix: Added an opt-in tempfile transport to handwritten root az.completion. For ARGCOMPLETE_USE_TEMPFILES=1 it creates a secure tempfile, passes _ARGCOMPLETE_STDOUT_FILENAME to az, reads successful candidates into COMPREPLY, removes the file on success or command failure, and clears previous/partial candidates while propagating failures. The existing descriptor invocation and nospace behavior are preserved when the flag is unset. Added focused shell-level unit tests sourcing the actual script, including an offline file-only Windows backend model and an installed-CLI scenario that …
Risks and limitations (from the job report):
Testing Guide
src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_tempfile_creation_failure,src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_tempfile_current_line,src/azure-cli-core/azure/cli/core/tests/test_argcomplete_shell.py::ArgcompleteShellTest::test_bash_completion_tempfile_failure.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.