Skip to content

Filter Empty AppHost selectable languages by feature flag#16713

Closed
mitchdenny wants to merge 1 commit intomainfrom
mitchdenny/fix-16661-empty-apphost-python-language
Closed

Filter Empty AppHost selectable languages by feature flag#16713
mitchdenny wants to merge 1 commit intomainfrom
mitchdenny/fix-16661-empty-apphost-python-language

Conversation

@mitchdenny
Copy link
Copy Markdown
Member

@mitchdenny mitchdenny commented May 4, 2026

Description

Filter the aspire-empty template's selectable languages through the same feature-flag gating already used by IsTemplateAvailable, so disabled experimental polyglot languages no longer appear in the language picker.

Bug: aspire new showed Python as a selectable language for the generic Empty AppHost template even when experimentalPolyglot:python was disabled. Selecting Python then failed with Unknown language: 'python'.

Root cause: The aspire-empty CallbackTemplate in CliTemplateFactory.GetTemplateDefinitions() hardcoded selectableAppHostLanguages to [csharp, typescript/nodejs, python], and NewCommand.PromptForAppHostLanguageAsync displayed that list directly. The same code path called _languageDiscovery.GetLanguageById("python") later, which returned null when the flag was off, producing the late Unknown language error.

Fix:

  • Filter selectableAppHostLanguages through _languageDiscovery.GetLanguageById via two new helpers (IsLanguageAvailable / FilterAvailableLanguages).
  • Tighten supportsLanguageCallback so explicit --language python is rejected up front when the flag is off (returns the standard Template '...' does not support language 'python'. error instead of the late Unknown language error).

The same gating now keeps any future experimental polyglot languages out of selectableAppHostLanguages lists 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):

# PowerShell
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16713"
# Bash
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16713

Scenario 1 — flag OFF (regression check)

# Make sure the experimental Python polyglot flag is OFF (it is by default).
# If you previously turned it on, clear it:
aspire config delete -g features.experimentalPolyglot:python

aspire new
# pick: "Empty AppHost"

Expected: Language picker shows only C# and TypeScript/JavaScript. Python must NOT appear.

Also try the explicit-language path:

aspire new aspire-empty --language python

Expected: Fails fast with Template 'aspire-empty' does not support language 'python'. (and not the old Unknown language: 'python').

Scenario 2 — flag ON (feature still works)

aspire config set -g features.experimentalPolyglot:python true

aspire new
# pick: "Empty AppHost"

Expected: Language picker now includes Python. Selecting Python successfully creates a Python AppHost.

aspire new aspire-empty --language python

Expected: Succeeds and scaffolds a Python AppHost.

Cleanup

aspire config delete -g features.experimentalPolyglot:python

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

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>
@mitchdenny mitchdenny requested a review from JamesNK as a code owner May 4, 2026 02:00
Copilot AI review requested due to automatic review settings May 4, 2026 02:00
@mitchdenny mitchdenny requested a review from davidfowl as a code owner May 4, 2026 02:00
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16713

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16713"

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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’s selectableAppHostLanguages through ILanguageDiscovery.GetLanguageById(...) so disabled experimental languages (e.g., Python) don’t appear in the picker.
  • Tightens supportsLanguageCallback so --language python is 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.

Comment on lines +121 to +133
[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);
}
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🎬 CLI E2E Test Recordings — 76 recordings uploaded (commit 2166ba7)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LatestCliCanStartStableChannelAppHost ▶️ View Recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25297422026

@mitchdenny
Copy link
Copy Markdown
Member Author

/deployment-test

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🚀 Deployment tests starting on PR #16713...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing May 4, 2026 04:35 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing May 4, 2026 04:35 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing May 4, 2026 04:35 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing May 4, 2026 04:35 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing May 4, 2026 04:35 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing May 4, 2026 04:35 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Deployment E2E Tests failed — 28 passed, 5 failed, 0 cancelled

View test results and recordings

View workflow run

Test Result Recording
Deployment.EndToEnd-AcaCompactNamingDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-KubernetesGatewayTlsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptVnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-NspStorageKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureStorageDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptExpressDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-FrontDoorDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureServiceBusDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaManagedRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureLogAnalyticsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaDeploymentErrorOutputTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksBlazorRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaExistingRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureEventHubsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AppServiceReactDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksVnetInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureContainerRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AuthenticationTests ✅ Passed
Deployment.EndToEnd-AzureAppConfigDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterWithRedisHelmDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCustomRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerInfraDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AksWithAzureResourcesDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AksVnetWithAzureResourcesDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobConnectivityDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AksMultipleNodePoolsDeploymentTests ❌ Failed ▶️ View Recording

Copy link
Copy Markdown
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mitchdenny
Copy link
Copy Markdown
Member Author

Closing because this was addressed by: #16666

@mitchdenny mitchdenny closed this May 5, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire new Empty AppHost shows disabled Python language option

3 participants