{"record":{"id":"99fe9baafced2b2b","repo":"microsoft/aspire","slug":"the-endpoint-name-on-resource-ts-resourcename-should-have-an","errorCode":null,"errorMessage":"The '{endpoint.Name}' on resource '{ts.ResourceName}' should have an associated DCP Service resource already set up","messagePattern":"The '(.+?)' on resource '(.+?)' should have an associated DCP Service resource already set up","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Dcp/DcpModelUtilities.cs","lineNumber":316,"sourceCode":"                if (!TryGetEndpoint(res, ts.EndpointName, out var endpoint))\n                {\n                    throw new InvalidDataException($\"Service '{ts.Service!.Metadata.Name}' refers to endpoint '{ts.EndpointName}' that does not exist\");\n                }\n\n                if (ts.Service?.HasCompleteAddress is not true)\n                {\n                    // This should never happen; if it does, we have a bug without a workaround for the user.\n                    throw new InvalidDataException($\"Container tunnel service {ts.Service?.Metadata.Name} should have valid address at this point\");\n                }\n\n                var serverSvc = allAppResources.Get().OfType<ServiceWithModelResource>().FirstOrDefault(swr =>\n                    string.Equals(swr.ModelResource.Name, ts.ResourceName, StringComparisons.ResourceName) &&\n                    string.Equals(swr.EndpointAnnotation.Name, endpoint.Name, StringComparisons.EndpointAnnotationName)\n                );\n                if (serverSvc is null)\n                {\n                    // Should never happen -- we should have created a Service for every endpoint exposed from a resource.\n                    throw new InvalidDataException($\"The '{endpoint.Name}' on resource '{ts.ResourceName}' should have an associated DCP Service resource already set up\");\n                }\n\n                var networkId = new NetworkIdentifier(ts.ContainerNetworkName!);\n                var address = string.IsNullOrEmpty(ts.TunnelInstanceName) ? containerHostName : KnownHostNames.DefaultContainerTunnelHostName;\n                var port = (int)ts.Service!.AllocatedPort!;\n\n                var tunnelAllocatedEndpoint = new AllocatedEndpoint(\n                    endpoint,\n                    address,\n                    port,\n                    EndpointBindingMode.SingleAddress,\n                    targetPortExpression: $$$\"\"\"{{- portForServing \"{{{ts.Service.Metadata.Name}}}\" -}}\"\"\",\n                    networkId\n                );\n                endpoint.AllAllocatedEndpoints.AddOrUpdateAllocatedEndpoint(networkId, tunnelAllocatedEndpoint);\n            }\n        }\n    }","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs#L298-L334","documentation":"Every endpoint exposed from a model resource should have had a corresponding DCP Service created during earlier phases. When a container tunnel looks up that Service (by resource name + endpoint name) and finds none, the internal contract is broken, so this throw fires.","triggerScenarios":"AddContainerTunnelAllocatedEndpoints searches allAppResources for a ServiceWithModelResource matching ts.ResourceName and endpoint.Name; none exists because Service creation was skipped, renamed, or the tunnel annotation is stale.","commonSituations":"Endpoint name changes not propagated to tunnel wiring; partial startup where services for some endpoints were never created; Aspire internal bugs around tunnel/proxy service generation.","solutions":["Restart the AppHost so all endpoint services are (re)created before tunnels are wired.","Verify endpoint names on the tunneled resource match those used by tunnel configuration.","Update Aspire packages; if reproducible, report as a bug since this path is documented as unreachable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    app.Run();\n}\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"should have an associated DCP Service\"))\n{\n    // restart to regenerate endpoint services; upgrade Aspire if reproducible\n}","preventionTips":["Don't mutate endpoint names/annotations after services are created mid-run.","Keep tunnel wiring in sync with endpoint definitions in one code change.","Update Aspire packages; the code documents this as an unreachable state."],"tags":["aspire","dcp","tunnel","service","invariant"],"backgroundTag":"internal-invariant-violation","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"}