-
Notifications
You must be signed in to change notification settings - Fork 268
Fix extension namespace handling #6671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
bb15f63 to
78e235c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes two extension namespace handling issues to improve the user experience when working with Azure Developer CLI extensions.
Changes:
- Added namespace conflict detection to prevent installation of extensions with overlapping namespaces (e.g., "ai" and "ai.agent")
- Implemented auto-install prompting for partial namespace scenarios where one extension creates a namespace command group but the user invokes a command for an uninstalled sibling extension
- Added comprehensive test coverage for both namespace conflict detection and partial namespace auto-install scenarios
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cli/azd/cmd/extension_namespace_test.go | New test file with comprehensive tests for namespace conflict detection, covering exact matches, prefix overlaps, case-insensitive comparisons, and non-conflicting sibling namespaces |
| cli/azd/cmd/extension.go | Added checkNamespaceConflict and namespacesConflict functions to detect and prevent conflicting namespace installations with helpful error messages |
| cli/azd/cmd/auto_install_builtin_test.go | Added tests for new helper functions (hasSubcommand, getCommandPath, buildNamespaceArgs) and comprehensive partial namespace detection scenarios |
| cli/azd/cmd/auto_install.go | Added tryAutoInstallForPartialNamespace function with helper methods to detect when auto-install should trigger for commands matching uninstalled extensions in sibling namespaces |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes #6211
Fixes #6637
This PR fixes two extension namespace handling issues
Conflicting namespace installation (#6211)
Problem: An old version of
microsoft.azd.ai.builderhad namespaceai, which overlaps withazure.ai.agents(namespaceai.agent). When both were installed,azd ai agent init -mwould fail because commands got routed to the wrong extension.Solution: Added
checkNamespaceConflict()to prevent installing extensions with conflicting namespaces (where one is a prefix of another). Returns clear error messages with actionable suggestions to uninstall the conflicting extension first.Auto-install not triggering for sibling namespaces (#6637)
Problem: When
azure.ai.finetune(namespaceai.finetuning) is installed, runningazd ai agent initshows theaicommand help instead of prompting to installazure.ai.agents. This happens because Cobra finds theaicommand (created by the finetuning extension) and doesn't recognizeagentas an unknown command.Solution: Added
tryAutoInstallForPartialNamespace()which detects when Cobra finds a namespace command but the remaining args don't match any known subcommand. It builds the full namespace (ai.agent) and checks for matching extensions to prompt for installation.Testing
Manual testing:
azure.ai.agentsinstalled →azd ai finetuning init→ prompts to installazure.ai.finetune✅ (Extension auto install not triggering on AI extensions if one is installed already #6637)Try installing extension with conflicting namespace → clear error with suggestion ✅ (ai agent extension

-mflag inconsistently not working #6211)