{"record":{"id":"f40a57eecbe9886e","repo":"microsoft/aspire","slug":"endpoint-0-for-resource-1-not-found","errorCode":null,"errorMessage":"Endpoint '{0}' for resource '{1}' not found.","messagePattern":"Endpoint '(.+?)' for resource '(.+?)' not found\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs","lineNumber":287,"sourceCode":"        {\n            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ResourceHasNoAllocatedEndpointsExceptionMessage, resourceName), nameof(resourceName));\n        }\n\n        EndpointReference? endpoint;\n        if (!string.IsNullOrEmpty(endpointName))\n        {\n            endpoint = GetEndpointOrDefault(resourceWithEndpoints, endpointName, networkIdentifier);\n        }\n        else\n        {\n            // Prefer https over http to match the default service discovery behavior (https+http://),\n            // where https is tried first.\n            endpoint = GetEndpointOrDefault(resourceWithEndpoints, \"https\", networkIdentifier) ?? GetEndpointOrDefault(resourceWithEndpoints, \"http\", networkIdentifier);\n        }\n\n        if (endpoint is null)\n        {\n            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.EndpointForResourceNotFoundExceptionMessage, endpointName, resourceName), nameof(endpointName));\n        }\n\n        return endpoint.Url;\n    }\n\n    static void ThrowIfNotStarted(DistributedApplication app, string exceptionMessage)\n    {\n        var lifetime = app.Services.GetRequiredService<IHostApplicationLifetime>();\n        if (!lifetime.ApplicationStarted.IsCancellationRequested)\n        {\n            throw new InvalidOperationException(exceptionMessage);\n        }\n    }\n\n    static EndpointReference? GetEndpointOrDefault(IResourceWithEndpoints resourceWithEndpoints, string endpointName, NetworkIdentifier? networkIdentifier = default)\n    {\n        var reference = resourceWithEndpoints.GetEndpoint(endpointName, networkIdentifier ?? KnownNetworkIdentifiers.LocalhostNetwork);\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Testing/DistributedApplicationHostingTestingExtensions.cs#L269-L305","documentation":"GetEndpointUriStringCore throws this ArgumentException when the requested endpoint name (or the implicit https/http fallback) cannot be resolved on the resource. After trying the explicit name or the https-then-http default pair, no EndpointReference matches, so the library fails fast.","triggerScenarios":"Calling app.GetEndpoint(\"frontend\", \"https\") when the project only defines an http endpoint; calling without an endpoint name on a resource that has neither https nor http endpoints; using a custom endpoint name not registered via WithEndpoint.","commonSituations":"Projects configured http-only being asked for https; endpoint renamed in the AppHost (WithEndpoint(name: ...)) but tests still use the old name; endpoints only added conditionally.","solutions":["Use an endpoint name that the resource actually defines (check WithEndpoint/WithHttpEndpoint calls in the AppHost)","If the project is http-only, request \"http\" explicitly or omit scheme assumptions","Add the missing endpoint in the AppHost if the test legitimately needs it"],"exampleFix":"// before\nvar url = app.GetEndpoint(\"frontend\", \"https\"); // http-only project\n// after\nvar url = app.GetEndpoint(\"frontend\", \"http\");","handlingStrategy":"validation","validationCode":"var res = (IResourceWithEndpoints)app.GetResource(name);\nvar endpoints = ((IResource)r).Annotations.OfType<EndpointAnnotation>().Select(a => a.Name).ToList();\n// ensure desired endpoint name is in endpoints before calling GetEndpoint","typeGuard":null,"tryCatchPattern":"try { var url = app.GetEndpoint(name, endpointName); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"not found\"))\n{\n    // fall back to the other scheme or a different endpoint name\n}","preventionTips":["Check WithEndpoint/WithHttpEndpoint names in the AppHost before hardcoding endpoint names","Remember the default fallback tries https then http only","For http-only projects request \"http\" explicitly"],"tags":["aspire","testing","endpoints","argument"],"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"}