{"record":{"id":"29e8c6bf821679e5","repo":"microsoft/aspire","slug":"could-not-create-errordisplaynoun-for-resource-builder-29e8c6","errorCode":null,"errorMessage":"Could not create {errorDisplayNoun} for resource '{builder.Resource.Name}' as no endpoint was found matching one of the specified names: {endpointNamesString}","messagePattern":"Could not create (.+?) for resource '(.+?)' as no endpoint was found matching one of the specified names: (.+?)","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ResourceBuilderExtensions.cs","lineNumber":4390,"sourceCode":"            var endpoints = builder.Resource.GetEndpoints();\n            EndpointReference? matchingEndpoint = null;\n\n            foreach (var name in endpointNames)\n            {\n                matchingEndpoint = endpoints.FirstOrDefault(e => string.Equals(e.EndpointName, name, StringComparisons.EndpointAnnotationName));\n                if (matchingEndpoint is not null)\n                {\n                    if (!s_httpSchemes.Contains(matchingEndpoint.Scheme, StringComparers.EndpointAnnotationUriScheme))\n                    {\n                        throw new DistributedApplicationException($\"Could not create {errorDisplayNoun} for resource '{builder.Resource.Name}' as the endpoint with name '{matchingEndpoint.EndpointName}' and scheme '{matchingEndpoint.Scheme}' is not an HTTP endpoint.\");\n                    }\n                    return matchingEndpoint;\n                }\n            }\n\n            // No endpoint found with the specified names\n            var endpointNamesString = string.Join(\", \", endpointNames);\n            throw new DistributedApplicationException($\"Could not create {errorDisplayNoun} for resource '{builder.Resource.Name}' as no endpoint was found matching one of the specified names: {endpointNamesString}\");\n        };\n\n    private static Func<EndpointReference> DefaultEndpointSelector<TResource>(IResourceBuilder<TResource> builder)\n        where TResource : IResourceWithEndpoints\n        => () =>\n        {\n            // Use the first HTTP endpoint (preferring HTTPS over HTTP), otherwise throw an exception if no endpoint is found.\n            var endpoints = builder.Resource.GetEndpoints();\n            EndpointReference? matchingEndpoint = null;\n\n            foreach (var scheme in s_httpSchemes)\n            {\n                matchingEndpoint = endpoints.FirstOrDefault(e => string.Equals(e.EndpointName, scheme, StringComparisons.EndpointAnnotationUriScheme));\n                if (matchingEndpoint is not null)\n                {\n                    return matchingEndpoint;\n                }\n            }","sourceCodeStart":4372,"sourceCodeEnd":4408,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ResourceBuilderExtensions.cs#L4372-L4408","documentation":"When creating an HTTP-based resource command, Aspire searches the resource's endpoints for one matching any of the configured candidate endpoint names. If none matches, it throws DistributedApplicationException listing all names it searched for.","triggerScenarios":"Calling WithHttpCommand-style APIs where the resource has no endpoint whose EndpointName matches any of the configured names — e.g. the resource never called WithEndpoint, or the endpoint name differs in case/spelling from the configured candidates.","commonSituations":"Assuming the default endpoint is named 'http'/'https' when it was named something custom like 'webui'; endpoints added conditionally so they are missing at command creation; renaming an endpoint without updating command configuration.","solutions":["Add a WithEndpoint/WithHttpEndpoint call matching one of the expected names on the resource","Pass an explicit endpoint name that matches the resource's declared endpoint","Check for spelling/case differences between the configured endpoint names and the actual endpoint annotations"],"exampleFix":"// before\n.WithHttpCommand(..., endpointName: \"https\") // resource only declares \"http\"\n// after\n.WithEndpoint(name: \"https\", scheme: \"https\", port: 8080) // or use endpointName: \"http\"","handlingStrategy":"validation","validationCode":"var names = resource.GetEndpoints().Select(e => e.EndpointName).ToHashSet(StringComparer.OrdinalIgnoreCase);\nvar missing = candidateNames.Where(n => !names.Contains(n)).ToList();\nif (missing.Count == candidateNames.Count)\n    throw new InvalidOperationException($\"No endpoint matches any of: {string.Join(\", \", candidateNames)}\");","typeGuard":"bool HasAnyNamedEndpoint(IResourceWithEndpoints r, IEnumerable<string> wanted) =>\n    r.GetEndpoints().Any(e => wanted.Contains(e.EndpointName, StringComparer.OrdinalIgnoreCase));","tryCatchPattern":"try { builder.WithHttpCommand(...); }\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"no endpoint was found matching\")) { /* declare the endpoint or correct the name */ }","preventionTips":["Match endpoint names exactly as declared in WithEndpoint","Declare required endpoints unconditionally if HTTP commands depend on them","Log available endpoint names when configuring commands to catch renames early"],"tags":["http","endpoint","resource-not-found","aspire-hosting"],"backgroundTag":"endpoint-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"}