Filter Empty AppHost selectable languages by feature flag#16713
Filter Empty AppHost selectable languages by feature flag#16713mitchdenny wants to merge 1 commit intomainfrom
Conversation
The aspire-empty CallbackTemplate hardcoded its selectable AppHost languages to [csharp, typescript/nodejs, python], so `aspire new` would present Python in the language picker even when the experimentalPolyglot:python feature flag was disabled. Selecting Python then failed with "Unknown language: 'python'" once the empty AppHost template asked DefaultLanguageDiscovery to resolve it. Run the selectable language list through ILanguageDiscovery so it matches the same gating used by GetLanguageById. Also tighten SupportsLanguage on the empty template so an explicit `--language python` is rejected up front when the feature flag is off, instead of failing later with the generic unknown-language error. Add tests asserting that: - The empty template only offers Python when the polyglot Python flag is enabled. - Passing --language python explicitly fails when the flag is off. Fixes #16661 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16713Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16713" |
There was a problem hiding this comment.
Pull request overview
This PR fixes a CLI UX bug where the aspire-empty (Empty AppHost) template would list Python as a selectable language even when the experimental polyglot Python feature flag was disabled, leading to a later “Unknown language” failure. It aligns the template’s selectable language list with the existing language discovery/feature-flag gating used for template availability.
Changes:
- Filters
aspire-empty’sselectableAppHostLanguagesthroughILanguageDiscovery.GetLanguageById(...)so disabled experimental languages (e.g., Python) don’t appear in the picker. - Tightens
supportsLanguageCallbackso--language pythonis rejected up front when Python is feature-flagged off. - Adds unit tests covering the Empty AppHost template’s selectable languages and
SupportsLanguage(...)behavior with polyglot Python enabled/disabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Aspire.Cli/Templating/CliTemplateFactory.cs | Filters the Empty AppHost template’s selectable languages and support checks using language discovery so feature-flagged languages don’t surface when disabled. |
| tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs | Adds tests validating the Empty AppHost template’s selectable languages/support behavior with the Python polyglot flag on/off. |
| [Fact] | ||
| public async Task NewCommandWithExplicitPythonOnEmptyTemplate_FailsWhenPolyglotPythonDisabled() | ||
| { | ||
| using var workspace = TemporaryWorkspace.Create(outputHelper); | ||
| var services = CreateServiceCollection(workspace); | ||
| using var provider = services.BuildServiceProvider(); | ||
|
|
||
| var command = provider.GetRequiredService<NewCommand>(); | ||
| var result = command.Parse($"new {KnownTemplateId.CSharpEmptyAppHost} --name TestApp --output . --language python"); | ||
|
|
||
| var exitCode = await result.InvokeAsync().DefaultTimeout(); | ||
| Assert.NotEqual(ExitCodeConstants.Success, exitCode); | ||
| } |
|
🎬 CLI E2E Test Recordings — 76 recordings uploaded (commit View all recordings
📹 Recordings uploaded automatically from CI run #25297422026 |
|
/deployment-test |
|
🚀 Deployment tests starting on PR #16713... This will deploy to real Azure infrastructure. Results will be posted here when complete. |
|
❌ Deployment E2E Tests failed — 28 passed, 5 failed, 0 cancelled View test results and recordings
|
JamesNK
left a comment
There was a problem hiding this comment.
Fix looks correct — the gating through IsLanguageAvailable / FilterAvailableLanguages is consistent with the existing IsTemplateAvailable pattern.
One note: please address the existing review comment on NewCommandWithExplicitPythonOnEmptyTemplate_FailsWhenPolyglotPythonDisabled — the test should also assert the error message text (e.g., contains "does not support language 'python'") rather than only checking for a non-success exit code.
|
Closing because this was addressed by: #16666 |
Description
Filter the
aspire-emptytemplate's selectable languages through the same feature-flag gating already used byIsTemplateAvailable, so disabled experimental polyglot languages no longer appear in the language picker.Bug:
aspire newshowed Python as a selectable language for the generic Empty AppHost template even whenexperimentalPolyglot:pythonwas disabled. Selecting Python then failed withUnknown language: 'python'.Root cause: The
aspire-emptyCallbackTemplateinCliTemplateFactory.GetTemplateDefinitions()hardcodedselectableAppHostLanguagesto[csharp, typescript/nodejs, python], andNewCommand.PromptForAppHostLanguageAsyncdisplayed that list directly. The same code path called_languageDiscovery.GetLanguageById("python")later, which returnednullwhen the flag was off, producing the lateUnknown languageerror.Fix:
selectableAppHostLanguagesthrough_languageDiscovery.GetLanguageByIdvia two new helpers (IsLanguageAvailable/FilterAvailableLanguages).supportsLanguageCallbackso explicit--language pythonis rejected up front when the flag is off (returns the standardTemplate '...' does not support language 'python'.error instead of the lateUnknown languageerror).The same gating now keeps any future experimental polyglot languages out of
selectableAppHostLanguageslists if added without enabling their feature flag.Fixes #16661
Validation
Install this PR build (one-liner — replace the URL host once a release branch is involved):
Scenario 1 — flag OFF (regression check)
Expected: Language picker shows only C# and TypeScript/JavaScript. Python must NOT appear.
Also try the explicit-language path:
Expected: Fails fast with
Template 'aspire-empty' does not support language 'python'.(and not the oldUnknown language: 'python').Scenario 2 — flag ON (feature still works)
Expected: Language picker now includes Python. Selecting Python successfully creates a Python AppHost.
Expected: Succeeds and scaffolds a Python AppHost.
Cleanup
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: