{"record":{"id":"b5e01421d9b1983e","repo":"microsoft/aspire","slug":"the-endpoint-endpointreference-endpointname-is-not-defined","errorCode":null,"errorMessage":"the endpoint '${endpointReference.EndpointName}' is not defined on resource '${endpointReference.Resource.Name}'","messagePattern":"the endpoint '(.+?)' is not defined on resource '(.+?)'","errorType":"exception","errorClass":"RadiusUnresolvableValueException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Radius/Publishing/RadiusInfrastructureBuilder.cs","lineNumber":4325,"sourceCode":"            }\n        }\n\n        return expressions;\n    }\n\n    /// <summary>\n    /// Rejects a reference to an endpoint the target resource does not declare, before any code\n    /// touches <see cref=\"EndpointReference.EndpointAnnotation\"/> (which raises a bare\n    /// <see cref=\"InvalidOperationException\"/> that would be indistinguishable from a real error).\n    /// </summary>\n    private static void ThrowIfEndpointMissing(EndpointReference endpointReference, IResource owner)\n    {\n        if (endpointReference.Exists)\n        {\n            return;\n        }\n\n        throw new RadiusUnresolvableValueException(\n            owner,\n            $\"the endpoint '{endpointReference.EndpointName}' is not defined on resource \" +\n            $\"'{endpointReference.Resource.Name}'\");\n    }\n\n    /// <summary>\n    /// Splices a composite <see cref=\"ReferenceExpression\"/> into ordered parts by interleaving\n    /// its literal <see cref=\"ReferenceExpression.Format\"/> chunks with the recursively-resolved\n    /// parts of each value provider (matching the <c>{0}</c>, <c>{1}</c>, ... placeholders).\n    /// </summary>\n    private async Task ResolveReferenceExpressionPartsAsync(ReferenceExpression expression, IResource owner, List<EnvPart> parts, IResource referencedResource, bool allowRecipeSubstitutions = true)\n    {\n        // A conditional expression carries no format at all and exposes the *union* of both\n        // branches' providers, so the splice below would resolve both branches — potentially\n        // failing the publish on the inactive one — and then append nothing, leaving the variable\n        // empty. Select the branch first, matching ReferenceExpression.GetValueAsync and\n        // ExpressionResolver.EvalExpressionAsync.\n        if (expression.IsConditional)","sourceCodeStart":4307,"sourceCodeEnd":4343,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Radius/Publishing/RadiusInfrastructureBuilder.cs#L4307-L4343","documentation":"An EndpointReference points to an endpoint name that does not exist on the referenced resource. During Radius publishing the publisher verifies endpoint existence before emitting connection values and throws RadiusUnresolvableValueException when EndpointReference.Exists is false.","triggerScenarios":"Calling GetEndpoint(\"name\") on a resource that never defines that endpoint (no WithEndpoint/WithHttpEndpoint with that name) and then using that EndpointReference in a value published to Radius.","commonSituations":"Typo in the endpoint name; endpoint added conditionally (e.g. only in Run mode) so publish-mode model lacks it; endpoint defined on a different resource than intended; refactoring renamed the endpoint.","solutions":["Correct the endpoint name in the EndpointReference to match an endpoint defined on the resource.","Define the endpoint on the resource with WithEndpoint/WithHttpEndpoint using the referenced name.","Check that the endpoint isn't added under a condition that doesn't hold in publish mode.","Verify the EndpointReference targets the right resource instance."],"exampleFix":"// before\nvar ep = cache.GetEndpoint(\"redis\"); // no 'redis' endpoint defined\n// after\ncache.WithEndpoint(targetPort: 6379, name: \"redis\");\nvar ep = cache.GetEndpoint(\"redis\");","handlingStrategy":"validation","validationCode":"var ep = resource.GetEndpoint(name);\nif (!ep.Exists)\n    throw new InvalidOperationException($\"Endpoint '{name}' must be defined (WithEndpoint) before use.\");","typeGuard":"static bool EndpointExists(IResource r, string name) =>\n    r.Annotations.OfType<EndpointAnnotation>().Any(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try { BuildEndpointValue(ep); }\ncatch (RadiusUnresolvableValueException ex) when (ex.Message.Contains(\"is not defined on resource\"))\n{ log.LogError(ex, \"Missing endpoint; add WithEndpoint for '{Endpoint}'.\", ep.EndpointName); }","preventionTips":["Always define endpoints with WithEndpoint/WithHttpEndpoint before referencing them.","Use constants for endpoint names to avoid typos.","Check for conditional endpoint registration that may not apply in publish mode.","Validate endpoint references in unit tests against the resource model."],"tags":["radius","endpoint","publishing","missing-endpoint"],"backgroundTag":"resource-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}