Skip to content

Conversation

@karolz-ms
Copy link
Member

Fixes #12823

This was my mistake when implementing context-aware EndpointReference evaluation

Copilot AI review requested due to automatic review settings November 20, 2025 18:00
@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 -- 13074

Or

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

Copilot finished reviewing on behalf of karolz-ms November 20, 2025 18:02
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 an issue where EndpointReference evaluation would return null immediately when an AllocatedEndpoint for a specific network context was missing, instead of properly waiting for it to be allocated. The fix ensures that a ValueSnapshot is created and added to the collection for the missing network context, so that the evaluation will wait (as intended) until the endpoint is allocated.

Key Changes:

  • Modified EndpointReferenceExpression.GetValueAsync() to create a new NetworkEndpointSnapshot with an empty ValueSnapshot when no snapshot exists for the requested network context, enabling proper waiting behavior
  • Added a test to verify that expression resolution waits (and times out) when an allocated endpoint for a specific network context is missing

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 logic to create and add a NetworkEndpointSnapshot with an empty ValueSnapshot when none exists for the network context, instead of returning null immediately
tests/Aspire.Hosting.Tests/ExpressionResolverTests.cs Added test ExpressionResolutionShouldWaitOnMissingAllocatedEndpoint and helper class TestHostResource to verify the fix works correctly

@karolz-ms karolz-ms merged commit 4f98a07 into main Nov 20, 2025
870 of 878 checks passed
@karolz-ms karolz-ms deleted the dev/karolz/endpoint-reference-evaluation branch November 20, 2025 19:06
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Nov 20, 2025
@karolz-ms
Copy link
Member Author

/backport to release/13.0

@github-actions
Copy link
Contributor

Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/19548391113

@github-actions
Copy link
Contributor

@karolz-ms backporting to "release/13.0" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Patch format detection failed.
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

karolz-ms added a commit that referenced this pull request Nov 20, 2025
…#13074)

* Expression resolver should wait on missing AllocatedEndpoint(s)

* Target test now passing

* ExpressionResolverTests passing
joperezr pushed a commit that referenced this pull request Nov 24, 2025
…#13074) (#13076)

* Expression resolver should wait on missing AllocatedEndpoint(s)

* Target test now passing

* ExpressionResolverTests passing
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.

[13.0] EndpointReference environment variable evaluating to http://: (i.e. missing host & port)

3 participants