Add HTTP command result support for AppHost HTTP commands#15664
Add HTTP command result support for AppHost HTTP commands#15664
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15664Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15664" |
There was a problem hiding this comment.
Pull request overview
Adds ATS-friendly support for surfacing HTTP command response bodies as command results, enabling exported metadata + generated polyglot projections to describe response handling (JSON/text/auto/none).
Changes:
- Introduces
HttpCommandResultModeandHttpCommandOptions.ResultMode, plus default logic to capture/format HTTP response bodies when opted in. - Adds an ATS-specific
withHttpCommandexport with an ATS-friendly DTO (HttpCommandExportOptions) and updates ATS scanning/codegen to respect[AspireDto(Name=...)]. - Updates stress playground endpoints and refreshes TypeScript/Go/Java/Python/Rust generation snapshots and tests.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs | Adds unit tests for result-mode behavior and content-type inference. |
| tests/Aspire.Hosting.RemoteHost.Tests/AtsCapabilityScannerTests.cs | Validates withHttpCommand capability export shape + DTO surface. |
| src/Aspire.Hosting/ApplicationModel/HttpCommandOptions.cs | Adds HttpCommandResultMode, ResultMode, and the ATS DTO for export options. |
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Implements default result capture logic and adds ATS export withHttpCommand. |
| src/Aspire.Hosting/Ats/AspireDtoAttribute.cs | Adds Name to control exported DTO naming. |
| src/Aspire.TypeSystem/AttributeDataReader.cs | Adds parsing support for [AspireDto] data (including Name). |
| src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs | Uses parsed DTO name when producing ATS DTO type info. |
| src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs | Uses scanned DTO names for TS interfaces + supports “direct options DTO” parameters. |
| src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs | Uses scanned DTO names for Python DTOs. |
| playground/Stress/Stress.AppHost/Program.cs | Adds sample HTTP commands demonstrating result modes. |
| playground/Stress/Stress.ApiService/Program.cs | Adds endpoints returning JSON/text to exercise the new result modes. |
| tests/**/Snapshots/.verified. | Updates polyglot SDK/codegen snapshots to include the new capability, DTO, and enum. |
Comments suppressed due to low confidence (1)
src/Aspire.Hosting/ResourceBuilderExtensions.cs:2431
- XML doc has a typo: "succesful" should be "successful".
/// is not specified, the command will be considered succesful if the response status code is in the 2xx range. Set
| return response.IsSuccessStatusCode | ||
| ? CommandResults.Success() | ||
| : CommandResults.Failure($"Request failed with status code {response.StatusCode}"); | ||
| return await GetDefaultHttpCommandResultAsync(response, commandOptions, context.CancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
The HTTP response is used to compute the command result but is never disposed. To avoid holding open the underlying connection/content stream, consider disposing the HttpResponseMessage in a finally after either GetCommandResult completes or the default result logic runs.
3622e08 to
81db386
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
81db386 to
abf2a0b
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23679147932 |
Description
Adds HTTP command result support for AppHost HTTP commands so response bodies can be surfaced in the CLI, dashboard, and generated polyglot SDKs.
This change:
HttpCommandResultModeandHttpCommandOptions.ResultModeHttpCommandExportOptionsso generated SDKs can surface the same behavioroptionsparameterGetDefaultHttpCommandResultAsyncplus integration coverage throughWithHttpCommandauto,json, andtextHTTP command result scenariosDuring review, the temporary ATS DTO rename support was removed. DTO names continue to come from the CLR type name.
Fixes #8729
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: