Skip to content

Conversation

@karolz-ms
Copy link
Member

Description

A fix to restore proper EndpointReference resolution behavior, which should wait on missing AllocatedEndpoint instead of resolving as empty value. This bug can break existing applications and tests.

Fixes #12823

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?

…#13074)

* Expression resolver should wait on missing AllocatedEndpoint(s)

* Target test now passing

* ExpressionResolverTests passing
Copilot AI review requested due to automatic review settings November 20, 2025 19:17
@github-actions
Copy link
Contributor

🚀 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 -- 13076

Or

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

Copilot finished reviewing on behalf of karolz-ms November 20, 2025 19:21
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 fixes a critical bug where EndpointReference evaluation would incorrectly resolve as an empty value instead of waiting for a missing AllocatedEndpoint. This change restores the proper asynchronous waiting behavior, preventing potential failures in applications and tests that depend on endpoint resolution.

Key Changes:

  • Modified EndpointReferenceExpression.GetValueAsync to create and wait on a ValueSnapshot<AllocatedEndpoint> when no snapshot exists for the requested network context, instead of immediately returning null
  • Added thread-safe handling using TryAdd to prevent race conditions when multiple threads attempt to create snapshots for the same network
  • Included comprehensive test coverage to verify the fix works correctly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Aspire.Hosting/ApplicationModel/EndpointReference.cs Fixed the endpoint resolution logic to create and wait on a ValueSnapshot instead of returning null when no AllocatedEndpoint exists for the requested network context
tests/Aspire.Hosting.Tests/ExpressionResolverTests.cs Added test ExpressionResolutionShouldWaitOnMissingAllocatedEndpoint to verify the fix, along with a minimal TestHostResource helper class

@joperezr joperezr added the Servicing-approved Approved for servicing release label Nov 24, 2025
@joperezr joperezr added this to the 13.0.1 milestone Nov 24, 2025
@joperezr joperezr merged commit 4af9992 into release/13.0 Nov 24, 2025
873 of 881 checks passed
@joperezr joperezr deleted the dev/karolz/13-backports branch November 24, 2025 23:25
This was referenced Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants