Fix Windows subscription ID quoting issue in Azure CLI authentication#4368
Merged
Conversation
This change fixes GitHub issue #4319 where Windows users encountered "Subscription '"UUID"' not found" errors when using Azure CLI authentication in v3.8.0. The issue had two root causes: 1. Provider's `az account show` command used shell-based execution with string interpolation, causing Windows to interpret quotes literally: `cmd.exe /c "az account show --subscription \"UUID\""` resulted in the subscription ID including literal quote characters. 2. The provider always passed subscription IDs to Azure SDK's AzureCLICredential, which has the same shell quoting bug. Changes: - pkg/provider/azure_cli.go: Replaced shell execution with direct argument arrays (exec.Command("az", args...)) to eliminate quote escaping issues entirely across all platforms. - pkg/provider/auth_azidentity.go: Query subscription info before creating CLI credential, and only pass subscription ID to Azure SDK when it's not the default. This restores pre-3.8 behavior for most users while working around the Azure SDK's shell quoting bug. - pkg/provider/auth_azidentity_test.go: Updated tests to accommodate new function signature and added test coverage for default vs non-default subscription handling. Fixes #4319 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Does the PR have any schema changes?Looking good! No breaking changes found. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4368 +/- ##
==========================================
- Coverage 59.68% 59.66% -0.02%
==========================================
Files 90 90
Lines 14146 14142 -4
==========================================
- Hits 8443 8438 -5
Misses 5045 5045
- Partials 658 659 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
blampe
approved these changes
Oct 22, 2025
| cliCmd = exec.CommandContext(ctx, "/bin/sh", "-c", commandLine) | ||
| cliCmd.Dir = "/bin" | ||
| } | ||
| cliCmd := exec.CommandContext(ctx, "az", args...) |
Contributor
Author
There was a problem hiding this comment.
As described in overview, I cribbed the original code from Azure SDK. Why, I wonder, did they use a shell?
Contributor
|
This PR has been shipped in release v3.10.0. |
3 similar comments
Contributor
|
This PR has been shipped in release v3.10.0. |
Contributor
|
This PR has been shipped in release v3.10.0. |
Contributor
|
This PR has been shipped in release v3.10.0. |
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.
Summary
Fixes #4319 - Windows users encountered "Subscription '"UUID"' not found" errors when using Azure CLI authentication in v3.8.0.
Root Cause
The issue had two causes:
Provider's
az account showcommand used shell-based execution (cmd.exe /c) with string interpolation, causing Windows to interpret quotes literally in the subscription ID parameter.Provider always passed subscription IDs to Azure SDK's AzureCLICredential, which has the same shell quoting bug in its
az account get-access-tokencommand.Solution
This PR implements the fix suggested by @stooj in the issue comments, with an additional optimization:
1. Fixed provider's
az account show(pkg/provider/azure_cli.go)exec.Command("az", args...)2. Intelligent subscription handling (pkg/provider/auth_azidentity.go)
IsDefaultfield fromaz account showoutput3. Updated tests (pkg/provider/auth_azidentity_test.go)
Benefits
✅ Fixes Windows CLI authentication - Eliminates quote escaping bug in provider code
✅ Restores pre-3.8 behavior - Default subscription users avoid Azure SDK bug
✅ No upstream dependency - Works around Azure SDK issue without waiting for fix
✅ Respects explicit configuration - Non-default subscriptions still work correctly
✅ Cross-platform compatible - Cleaner code works on all platforms
✅ All tests pass - Full provider test suite passes
Test Plan
Related Analysis
See issue comments for detailed analysis:
🤖 Generated with Claude Code