Skip to content

Fix flaky E2E test: retry MSBuild evaluation on empty output#14868

Merged
davidfowl merged 2 commits intorelease/13.2from
fix/14819-detach-json-bleed
Mar 3, 2026
Merged

Fix flaky E2E test: retry MSBuild evaluation on empty output#14868
davidfowl merged 2 commits intorelease/13.2from
fix/14819-detach-json-bleed

Conversation

@mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Mar 3, 2026

Description

Fixes the flaky DetachFormatJsonProducesValidJson E2E test in MultipleAppHostTests.

Root Cause

When running aspire run --detach --format json while a previous detached AppHost is still running, the CLI calls dotnet msbuild -getProperty:... -getItem:... to evaluate project properties during AppHost discovery. Intermittently, this MSBuild evaluation returns exit code 0 but produces empty stdout output — likely due to MSBuild server contention with the already-running AppHost's build processes.

The empty output then caused JsonDocument.Parse("") to throw:

An unexpected error occurred: The input does not contain any JSON tokens.
Expected the input to start with a valid JSON token, when isFinalBlock is true.
LineNumber: 0 | BytePositionInLine: 0.

This was confirmed by downloading and analyzing the asciinema recording from the original failing CI run (artifact from PR #14811 run 22528127115).

Fix

Added retry logic (up to 3 attempts with increasing delay) in DotNetCliRunner.GetProjectItemsAndPropertiesAsync specifically for the case where MSBuild returns success but produces no output. This makes project discovery resilient to transient MSBuild server contention without changing the behavior for normal success or error cases.

Fixes #14819

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Whitespace change to trigger CI pipeline and E2E test execution
for reproducing the flaky DetachFormatJsonProducesValidJson test.

Fixes #14819

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 3, 2026 03:21
@github-actions
Copy link
Contributor

github-actions bot commented Mar 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14868

Or

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

Copy link
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 is intended to retrigger CI to help reproduce and investigate the flaky DetachFormatJsonProducesValidJson end-to-end test failure (stdout “bleed” into JSON output) described in #14819.

Changes:

  • Adds a trailing newline at the end of MultipleAppHostTests.cs (no functional/test logic changes).

When dotnet msbuild -getProperty/-getItem returns exit code 0 but
produces no stdout output (likely due to MSBuild server contention
when another AppHost process is running), JsonDocument.Parse would
throw 'The input does not contain any JSON tokens', crashing the
aspire run --detach --format json command.

This fix adds retry logic (up to 3 attempts with increasing delay)
for this specific case, making the project discovery more resilient
to concurrent MSBuild operations.

Fixes #14819

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mitchdenny mitchdenny changed the title Investigate flaky DetachFormatJsonProducesValidJson test (output bleed race) Fix flaky E2E test: retry MSBuild evaluation on empty output Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 7ff3e55:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ 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
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ❌ Upload failed
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22607222648

@davidfowl davidfowl merged commit 518cd60 into release/13.2 Mar 3, 2026
684 of 685 checks passed
@davidfowl davidfowl deleted the fix/14819-detach-json-bleed branch March 3, 2026 06:26
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 3, 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.

4 participants