Use extension source picker during init#8666
Conversation
Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
|
@copilot are there any other scenarios where this error could end up being thrown, where an interactive prompt would have been better instead? |
Yes. The remaining cases are dependency resolution inside
Top-level |
There was a problem hiding this comment.
Pull request overview
This PR updates azd init’s required-extension install flow to reuse the existing multi-source extension selection UI, so init no longer fails immediately when an extension ID is available from multiple sources.
Changes:
- Reuses
selectDistinctExtensionduringazd initrequired-extension resolution, prompting the user when multiple sources match. - Enhances the shared source picker to preselect the built-in
azdsource when present (case-insensitive). - Adds unit tests for the new default-source selection behavior.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/cmd/init.go | Routes init’s required-extension resolution through the shared multi-source picker and resumes the install spinner after selection. |
| cli/azd/cmd/extension.go | Makes the picker resilient to a nil global options pointer and adds default selection logic preferring the azd source. |
| cli/azd/cmd/extension_coverage3_test.go | Adds coverage for default source selection behavior (azd preferred, otherwise first). |
Copilot's findings
Comments suppressed due to low confidence (1)
cli/azd/cmd/extension.go:2135
- When
--no-promptis set and an extension resolves to multiple sources, this suggestion currently tells users to use--source. That flag exists onazd extension ...commands but not onazd init, which now also callsselectDistinctExtension, so the guidance can be misleading in that scenario. Consider making the suggestion context-agnostic (e.g., tell users to rerun with prompts enabled or pre-install the extension from the desired source viaazd extension install --source).
if global != nil && global.NoPrompt {
return nil, &internal.ErrorWithSuggestion{
Err: fmt.Errorf("the %s extension was found in multiple sources.", extensionId),
Suggestion: "Specify the extension source using the --source flag.",
}
- Files reviewed: 3/3 changed files
- Comments generated: 0
|
@JeffreyCA UX looks good. Thanks! Minor comment on the below prompt: it shows double colon. Can we fix it to show only one colon? |
📋 Milestone: June 2026This work is tracked for June 2026. The team will review it soon! |
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 #6236
This PR makes
azd initreuse the sharedselectDistinctExtensionsource picker when installing the extensions required byazure.yaml. Previously, if a required extension was found in more than one source, init failed outright with a generic "found in multiple sources, specify exact source" error. Now the user is prompted to choose the source interactively, with the built-inazdsource pre-selected as the default when present (matched case-insensitively), so the common case is a single keypress. The spinner is correctly stopped before the prompt and resumed afterward so the installation progress display stays consistent.Without change
Recording.2026-06-16.143958.mp4
With change
Recording.2026-06-16.143753.mp4
Known limitation: when
azd initis run with--no-promptand a required extension resolves to multiple sources, the surfaced error suggests using the--sourceflag. That flag exists on theazd extension ...commands but not onazd init, whose extension set is derived fromazure.yaml. Accepting this as a known limitation for now, as users can work around this by installing the extension first beforeinit.