{"record":{"id":"39a1cf77205f7db8","repo":"microsoft/aspire","slug":"could-not-create-errordisplaynoun-for-resource-builder","errorCode":null,"errorMessage":"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.","messagePattern":"Could not create (.+?) for resource '(.+?)' as the endpoint with name '(.+?)' and scheme '(.+?)' is not an HTTP endpoint\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ResourceBuilderExtensions.cs","lineNumber":4382,"sourceCode":"    // if found.\n    private static readonly string[] s_httpSchemes = [\"https\", \"http\"];\n\n    private static Func<EndpointReference> NamedEndpointSelector<TResource>(IResourceBuilder<TResource> builder, string[] endpointNames, string errorDisplayNoun)\n        where TResource : IResourceWithEndpoints\n        => () =>\n        {\n            // Find a matching endpoint using those names and if not an HTTP endpoint or not found throw an exception.\n            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","sourceCodeStart":4364,"sourceCodeEnd":4400,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ResourceBuilderExtensions.cs#L4364-L4400","documentation":"When creating an HTTP-based resource command with an explicit endpoint name, Aspire looks up the endpoint by name and verifies its scheme is http/https. If the named endpoint exists but has a non-HTTP scheme (e.g. tcp), it throws DistributedApplicationException identifying the endpoint and its scheme.","triggerScenarios":"Calling WithHttpCommand (or similar) with an endpointName that matches an endpoint declared via WithEndpoint(scheme: \"tcp\") or another non-HTTP scheme.","commonSituations":"Reusing an endpoint name defined for a raw TCP/UDP port; a scheme typo in the endpoint declaration ('htps'); endpoints declared programmatically with custom schemes for internal protocols.","solutions":["Declare (or select) an endpoint with scheme http or https for the HTTP command","Fix the scheme typo in the WithEndpoint call if the endpoint is actually HTTP","Use a different endpointName that refers to the HTTP endpoint"],"exampleFix":"// before\n.WithEndpoint(name: \"admin\", scheme: \"tcp\") // later used for HTTP command\n// after\n.WithEndpoint(name: \"admin\", scheme: \"https\")","handlingStrategy":"validation","validationCode":"var ep = resource.GetEndpoint(endpointName);\nif (ep is { } resolved && !s_httpSchemes.Contains(resolved.Scheme))\n    throw new InvalidOperationException($\"Endpoint '{endpointName}' scheme '{resolved.Scheme}' is not HTTP\");","typeGuard":"bool IsHttpScheme(string? scheme) => scheme is \"http\" or \"https\";","tryCatchPattern":"try { builder.WithHttpCommand(..., endpointName: name); }\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"is not an HTTP endpoint\")) { /* redeclare endpoint with http/https */ }","preventionTips":["Keep HTTP-facing endpoints declared with http/https schemes","Use distinct endpoint names for TCP/UDP endpoints to avoid accidental selection"],"tags":["http","endpoint","scheme","aspire-hosting"],"backgroundTag":"invalid-argument-value","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"}