Skip to content

Improve log message when waiting for an endpoint to be allocated#15474

Merged
adamint merged 1 commit intomicrosoft:mainfrom
afscrome:endpoint-resolution-log
Mar 22, 2026
Merged

Improve log message when waiting for an endpoint to be allocated#15474
adamint merged 1 commit intomicrosoft:mainfrom
afscrome:endpoint-resolution-log

Conversation

@afscrome
Copy link
Contributor

Description

Improve log message when waiting for an endpoint to be allocated.

Previously it would have said

Waiting for value from Aspire.Hosting.ApplicationModel.EndpointReference.

Now it says

Waiting for endpoint 'http' on resource 'nginx' for the 'unknownnetwork' network

Fixes #13912

If you want to reproduce this, easiest way is to use an endpoint reference on a network aspire doesn't know about:

var nginx = builder.AddContainer("nginx", "nginx", "latest")
       .WithHttpEndpoint(targetPort: 8080);

builder.AddExecutable("test", "test", ".")
       .WithArgs(nginx.GetEndpoint("http", new("unknownnetwork")))
       .WithArgs(nginx.GetEndpoint("http", new("unknownnetwork")).Property(EndpointProperty.Url))
       ;

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?

Copilot AI review requested due to automatic review settings March 21, 2026 20:56
@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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15474

Or

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

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

Improves the “waiting for value” log output during runtime value resolution by providing a more specific message when the unresolved value is an EndpointReference (or EndpointReferenceExpression), addressing #13912.

Changes:

  • Add a specialized log message for unresolved endpoint references (includes endpoint name, resource name, and network ID when present).
  • Introduce a helper (TryGetEndpointReference) to extract an EndpointReference from either EndpointReference or EndpointReferenceExpression.

Comment on lines +618 to +622
logger.LogInformation(
"Waiting for endpoint '{EndpointName}' on resource '{ResourceName}' for the '{NetworkName}' network",
endpointReference.EndpointName,
endpointReference.Resource.Name,
endpointReference.ContextNetworkID?.Value);
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

The logged network name is taken only from endpointReference.ContextNetworkID. If ContextNetworkID is null (the common case), the message will log a null/empty network even though endpoint resolution actually uses ValueProviderContext.GetNetworkIdentifier() (caller default network) in EndpointReferenceExpression.GetValueAsync. Consider logging the same effective network context used for resolution (e.g., endpointReference.ContextNetworkID ?? valueProviderContext.GetNetworkIdentifier()), or adjust the message to omit the network portion when it’s not explicitly set.

Copilot uses AI. Check for mistakes.
@adamint adamint merged commit 1053b41 into microsoft:main Mar 22, 2026
254 of 255 checks passed
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.

Improve message if resoruce is waiting for an EndpointReference to be allocated

3 participants