ExpressionResolver should throw when resolving endpoints that do not have AllocatedEndpoint infomration.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 201
Description
### Describe the bug
When using resource.GetEndpoint("endpointname") to populate environment variables, Aspire currently falls back to localhost or host.docker.internal if the named endpoint doesn’t exist. This silently hides configuration mistakes (e.g., typos or missing endpoints).
Example
```csharp
.WithEnvironment(ctx =>
{
ctx.EnvironmentVariables["MY_VAR"] = resource.GetEndpoint("endpointname").Property(EndpointProperty.Host));
});
```
# Current behavior
If "endpointname" does not exist, resolution defaults to localhost or host.docker.internal depending on the resource relationship. No error is raised, leading to subtle misconfiguration.
# Expected behavior
Throw a clear, actionable error when attempting to resolve a non-existent endpoint name to a concrete value (Host, Port, Scheme, Url, etc.).
Error message should include the resource name and a list of available endpoints on that resource.
Rationale
Contributor guide
Research direction
Start by locating ExpressionResolver and the resource.GetEndpoint resolution path, then trace how missing AllocatedEndpoint information becomes fallback host values. Done means resolving a nonexistent endpoint property raises a clear error containing the resource name and available endpoints; verify the relevant resolution behavior with the existing test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100