Revert: Fix env var leak when running extension commands with -e flag (#7035)#7274
Conversation
…Azure#7035)" This reverts commit 5fa9424.
There was a problem hiding this comment.
Pull request overview
Reverts the earlier change that pre-parsed -e/--environment in ParseGlobalFlags() (to prevent env var leakage into extension processes), because that early parsing conflicts with extensions that already use -e for other meanings (e.g., --project-endpoint).
Changes:
- Removes early parsing/storage of environment name from
GlobalCommandOptionsandParseGlobalFlags(). - Reverts extension invocation and environment resolution back to relying on Cobra flags/context only.
- Removes tests that asserted end-to-end global flag propagation into extension child processes.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/extensions/runner_test.go | Deletes the runner invoke env-var propagation test added in the reverted change. |
| cli/azd/internal/global_command_options.go | Removes EnvironmentName from global options. |
| cli/azd/cmd/extensions.go | Reverts extension invoke option population to read from cmd.Flags() instead of pre-parsed global options. |
| cli/azd/cmd/container.go | Reverts EnvFlag resolver to no longer consult global options as a fallback. |
| cli/azd/cmd/auto_install_test.go | Removes tests for environment-name parsing and validation in ParseGlobalFlags(). |
| cli/azd/cmd/auto_install.go | Removes early --environment flag parsing/validation; adjusts parse failure error string. |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
|
Thanks @achauhan-scc for manual testing |


Revert of #7035
Reason: The
-eshorthand added for--environmentinParseGlobalFlags()conflicts with extensions that already use-efor--project-endpoint.Regression: #7271
ParseGlobalFlags()runs before Cobra, consuming-e <url>and attempting to validate the URL as an environment name — which fails. This breaks:azure.ai.models(-efor--project-endpoint)azure.ai.finetune(-efor--project-endpoint)What this reverts
-e/--environmentfromParseGlobalFlags()(auto_install.go)EnvironmentNamefield fromGlobalCommandOptionsextensions.goto usecmd.Flags()for environment instead ofglobalOptionsFollow-up
The original env var leak issue should be re-addressed in a way that doesn't conflict with extension flags. Options:
--environment(long form) inParseGlobalFlags(), skip-eshorthandParseGlobalFlags()for extension commandsazure.ai.modelsandazure.ai.finetuneteams to migrate from-eto-pfor--project-endpoint(requires AI Foundry UI output changes and documentation updates) — cc @achauhan-sccNote: No external customer reports yet. Revert unblocks/fixes released models and fine-tuning extensions team while they plan the flag migration.
Build and snapshot tests pass locally.