Skip to content

[Core] Fix #34150: az: Support tempfile-backed Git Bash completion - #34248

Draft
Aditya Pujara (a0x1ab) wants to merge 1 commit into
Azure:devfrom
a0x1ab:agent-assist/azure-azure-cli-issue-34150-6d5179713b91
Draft

Aditya Pujara (a0x1ab) wants to merge 1 commit into
Azure:devfrom
a0x1ab:agent-assist/azure-azure-cli-issue-34150-6d5179713b91

Conversation

@a0x1ab

@a0x1ab Aditya Pujara (a0x1ab) commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes Tests
️✔️ None ️✔️ 130/130

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-merge label 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):

  • This host is Linux: Windows 11 MSI/Git Bash ReproSpec still requires a Windows platform-owner run …
  • Repository CI and supported-platform coverage remain required. No Azure live resources or new recordings are …
  • In-session validator cannot automatically compare non-Python shell source to an unavailable base revision and warns …

Testing Guide

  • 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.

History Notes

Generated from the pull request title.


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

…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
@x-engineering-agent x-engineering-agent Bot added Request X Engineering Agent Ask the agent to triage this issue or review this PR X Engineering Agent Generated Agent opened this PR do-not-merge labels Oct 20, 2026
@x-engineering-agent

x-engineering-agent Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

X Engineering Agent Report

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.

Posted by x-engineering-agent (Tester)

@a0x1ab

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@x-engineering-agent x-engineering-agent Bot added the X Engineering Agent Reviewed Agent reviewed this PR label Oct 20, 2026
@a0x1ab Aditya Pujara (a0x1ab) added Request X Engineering Agent Ask the agent to triage this issue or review this PR and removed Request X Engineering Agent Ask the agent to triage this issue or review this PR labels Oct 21, 2026

This branch has not been deployed

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

Labels

act-platform-engineering-squad Auto-Assign Auto assign by bot Core CLI core infrastructure do-not-merge Request X Engineering Agent Ask the agent to triage this issue or review this PR X Engineering Agent Generated Agent opened this PR X Engineering Agent Reviewed Agent reviewed this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for cli completion in git bash for windows

1 participant