Skip to content

Surface process output on failure#16303

Merged
davidfowl merged 4 commits intomainfrom
davidfowl/bicep-build-output
Apr 20, 2026
Merged

Surface process output on failure#16303
davidfowl merged 4 commits intomainfrom
davidfowl/bicep-build-output

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

Description

  • Generalize failed-process output retention into the DCP process layer by letting ProcessSpec opt into retained output and returning that retained output from ProcessResult.
  • Surface the retained output tail for publishing and container-runtime failures, including dotnet publish, Docker/Podman build, registry login, and compose up failures.
  • Rename the generic failure surface from build output to process output, and fix the shared CircularBuffer debug assertions so duplicate values do not trip incorrect invariants.

Motivation/context:

  • This makes opaque failures like az bicep build and other process-driven deployment steps include the useful stderr/stdout tail by default.

Dependencies:

  • None.

Validation:

  • ./dotnet.sh build src/Aspire.Hosting/Aspire.Hosting.csproj -c Release
  • ./dotnet.sh build src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj -c Release
  • ./dotnet.sh build src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj -c Release
  • ./dotnet.sh build src/Aspire.Hosting.Azure.Kubernetes/Aspire.Hosting.Azure.Kubernetes.csproj -c Release
  • ./dotnet.sh test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj -- --filter-class "*.ContainerRuntimeBaseTests" --filter-class "*.ProcessUtilTests" --filter-class "*.ProcessFailedExceptionTests" --filter-class "*.ResourceContainerImageManagerTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
  • ./dotnet.sh test tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj -- --filter-class "*.CircularBufferTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Fixes # (issue)

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?

Generalize failed-process output retention in ProcessUtil and ProcessResult, update publishing failure paths to surface retained output, and add regression coverage for compose-up failures and CircularBuffer duplicate-value assertions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 18, 2026 22:53
@davidfowl davidfowl requested a review from eerhardt as a code owner April 18, 2026 22:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 18, 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 -- 16303

Or

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

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 improves failure diagnostics across Aspire’s publishing/container runtime flows by retaining and surfacing a bounded tail of process stdout/stderr from the shared DCP process layer, and updates the shared CircularBuffer debug assertions to handle duplicate values correctly.

Changes:

  • Add opt-in (and failure-default) retained process output to ProcessSpec/ProcessResult, and use it to enrich exception messages for publish/container-runtime failures.
  • Rename “build output” terminology to “process output” across publishing exceptions and tests.
  • Fix CircularBuffer debug assertions for duplicate values and add regression tests.
Show a summary per file
File Description
tests/Aspire.Hosting.Tests/Publishing/ResourceContainerImageManagerTests.cs Updates test to validate ProcessFailedException.ProcessOutput instead of BuildOutput.
tests/Aspire.Hosting.Tests/Publishing/ProcessFailedExceptionTests.cs Renames variables/expectations to “process output” and validates truncation messaging.
tests/Aspire.Hosting.Tests/Publishing/ContainerRuntimeBaseTests.cs Adds coverage ensuring registry login / compose up failures include captured output.
tests/Aspire.Hosting.Tests/Dcp/ProcessUtilTests.cs Adds tests for default failure output capture, opt-in retention in ProcessResult, and truncation behavior.
tests/Aspire.Dashboard.Tests/CircularBufferTests.cs Adds regression tests for duplicate-value behavior when full.
src/Shared/CircularBuffer.cs Adjusts debug assertions to handle duplicates by counting occurrences.
src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs Enables retained output for dotnet publish and passes it into ProcessFailedException.
src/Aspire.Hosting/Publishing/ProcessFailedException.cs Renames surfaced output to “process output” and formats via shared formatter.
src/Aspire.Hosting/Publishing/DockerContainerRuntime.cs Switches build/buildx failure paths to use ProcessResult retained output.
src/Aspire.Hosting/Publishing/PodmanContainerRuntime.cs Switches build failure paths to use ProcessResult retained output.
src/Aspire.Hosting/Publishing/ContainerRuntimeBase.cs Adds ExecuteContainerCommandWithResultAsync and includes formatted retained output in login/compose up failures.
src/Aspire.Hosting/Dcp/Process/ProcessUtil.cs Implements retained output capture and appends formatted tail to non-zero-exit exceptions.
src/Aspire.Hosting/Dcp/Process/ProcessSpec.cs Adds DefaultRetainedOutputLineCount and RetainedOutputLineCount knob.
src/Aspire.Hosting/Dcp/Process/ProcessResult.cs Carries retained output + total line count and provides formatting helper.
src/Aspire.Hosting/Dcp/Process/ProcessOutputCapture.cs Introduces shared output tail capture/formatting utility under Aspire.Hosting.Utils.
src/Aspire.Hosting.Docker/Aspire.Hosting.Docker.csproj Links ProcessOutputCapture.cs into shared compile set.
src/Aspire.Hosting.Azure/Aspire.Hosting.Azure.csproj Links ProcessOutputCapture.cs into shared compile set.
src/Aspire.Hosting.Azure.Kubernetes/Aspire.Hosting.Azure.Kubernetes.csproj Links ProcessOutputCapture.cs into shared compile set.

Copilot's findings

Comments suppressed due to low confidence (1)

src/Shared/CircularBuffer.cs:201

  • removedItemCount = CountOccurrences(removedItem) is executed unconditionally, but it exists only to support the subsequent Debug.Assert. Since Debug.Assert calls are removed in non-DEBUG builds, this leaves an unnecessary O(n) scan on every Add once the buffer is full. Wrap the counting (and assert) in #if DEBUG (or similar) so release builds keep O(1) behavior.
            var removedItem = this[0];
            var removedItemCount = CountOccurrences(removedItem);

  • Files reviewed: 18/18 changed files
  • Comments generated: 2

Comment thread src/Shared/CircularBuffer.cs
Comment thread src/Aspire.Hosting/Publishing/ContainerRuntimeBase.cs
davidfowl and others added 3 commits April 18, 2026 16:05
Tighten the updated tests to assert stable retained-output behavior instead of exact external tool wording.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make CircularBuffer duplicate-count assertions debug-only so release builds keep O(1) behavior, and clarify the ProcessResult helper summary to describe non-zero-exit behavior accurately.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

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.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 72 recordings uploaded (commit 95d99c5)

View recordings
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 ▶️ 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
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
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ 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
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24616742709

Copy link
Copy Markdown
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

Clean, well-structured refactoring. Behavioral contracts are preserved across all call sites, thread safety is maintained, and the CircularBuffer assertion fix correctly handles duplicate values. Test coverage is thorough. No issues found.

@davidfowl davidfowl merged commit dca213e into main Apr 20, 2026
560 of 565 checks passed
@github-actions github-actions bot added this to the 13.3 milestone Apr 20, 2026
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.

Clean PR — no bugs, security issues, correctness errors, or convention violations found.

Verified: all callers migrated from BuildOutputCapture to the new ProcessOutputCapture/RetainedOutputLineCount pattern, linked .csproj includes are consistent, CircularBuffer debug assertions correctly handle duplicates, no credential leak risk in login output capture, and logging levels are preserved through the refactoring.

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.

4 participants