Skip to content

Add polyglot endpoint callback exports#15856

Merged
sebastienros merged 5 commits into
mainfrom
sebros/issue-15854-ts-endpoint-overloads
Apr 13, 2026
Merged

Add polyglot endpoint callback exports#15856
sebastienros merged 5 commits into
mainfrom
sebros/issue-15854-ts-endpoint-overloads

Conversation

@sebastienros
Copy link
Copy Markdown
Contributor

Description

Add polyglot-safe endpoint mutation callbacks for AppHosts so existing endpoints can be updated by name without changing the creation semantics of withEndpoint(...) or withHttpEndpoint(...).

This change introduces an ATS-safe EndpointUpdateContext wrapper and exports separate callback-based mutation APIs:

  • withEndpointCallback(...)
  • withHttpEndpointCallback(...)

These are generated into the TypeScript, Java, and Python AppHost surfaces and covered by the shared polyglot apphost samples. This enables scenarios like mutating an auto-created http endpoint, including the Vite endpoint case from the issue.

Fixes #15854

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?

Copilot AI review requested due to automatic review settings April 3, 2026 19:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 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 -- 15856

Or

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

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 adds polyglot-safe endpoint mutation callback exports so TypeScript/Java/Python AppHosts can update already-created endpoints (e.g., auto-created http endpoints) by name without changing existing endpoint creation semantics.

Changes:

  • Introduces EndpointUpdateContext as an ATS-safe wrapper for mutating endpoint settings in polyglot callbacks.
  • Adds new exported mutation capabilities: withEndpointCallback(...) and withHttpEndpointCallback(...) (plus generated SDK surface updates).
  • Updates polyglot AppHost samples and codegen snapshots to validate the new callback APIs.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/PolyglotAppHosts/Aspire.Hosting/TypeScript/apphost.ts Adds usage coverage for endpoint callback mutation APIs in TS AppHost sample.
tests/PolyglotAppHosts/Aspire.Hosting/Python/apphost.py Adds usage coverage for endpoint callback mutation APIs in Python AppHost sample.
tests/PolyglotAppHosts/Aspire.Hosting/Java/AppHost.java Adds usage coverage for endpoint callback mutation APIs in Java AppHost sample.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts Updates TS generated surface to include EndpointUpdateContext and callback methods/options.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt Adds the new capability IDs to the TS codegen capability snapshot.
tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py Updates Python generated surface to include EndpointUpdateContext and callback methods/kwargs.
tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java Updates Java generated surface to include EndpointUpdateContext and callback methods/options.
src/Aspire.Hosting/ResourceBuilderExtensions.cs Adds internal exported endpoint mutation methods and updates polyglot guidance/ignore reason text.
src/Aspire.Hosting/ApplicationModel/EndpointUpdateContext.cs Introduces the new exported context wrapper type for endpoint mutation.

Comment thread src/Aspire.Hosting/ApplicationModel/EndpointUpdateContext.cs
Comment thread src/Aspire.Hosting/ApplicationModel/EndpointUpdateContext.cs
Comment thread src/Aspire.Hosting/ResourceBuilderExtensions.cs
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.

3 comments: 1 likely bug (missing WithHttpsEndpointCallback symmetry), 1 unnecessary complexity (reflection in test when InternalsVisibleTo is available), 1 minor (unrelated blank line removal).

Comment thread src/Aspire.Hosting/ResourceBuilderExtensions.cs
Comment thread tests/Aspire.Hosting.Tests/WithEndpointTests.cs Outdated
Comment thread src/Aspire.Hosting/ResourceBuilderExtensions.cs
sebastienros and others added 4 commits April 13, 2026 08:28
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sebastienros sebastienros force-pushed the sebros/issue-15854-ts-endpoint-overloads branch from ab19db9 to 60fc265 Compare April 13, 2026 15:35
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sebastienros sebastienros merged commit 2ab4294 into main Apr 13, 2026
279 checks passed
@sebastienros sebastienros deleted the sebros/issue-15854-ts-endpoint-overloads branch April 13, 2026 16:46
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 68 recordings uploaded (commit a38e9dd)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AllPublishMethodsBuildDockerImages ▶️ 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
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ 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
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ 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
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ 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
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24353404414

@joperezr joperezr added this to the 13.3 milestone Apr 14, 2026
radical pushed a commit that referenced this pull request Apr 14, 2026
* Add endpoint callback exports for polyglot apphosts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Make endpoint update context internal

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix HTTP endpoint callback creation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Regenerate endpoint callback snapshots

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address PR review comments

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript apphost: withEndpoint/withHttpEndpoint lacks callback overload to modify existing endpoints

6 participants