{"record":{"id":"686bf8bc8755a42d","repo":"microsoft/aspire","slug":"container-tunnel-service-ts-service-metadata-name-should","errorCode":null,"errorMessage":"Container tunnel service {ts.Service?.Metadata.Name} should have valid address at this point","messagePattern":"Container tunnel service (.+?) should have valid address at this point","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Dcp/DcpModelUtilities.cs","lineNumber":306,"sourceCode":"            ))\n            .Where(ts =>\n                ts.Service is not null &&\n                string.Equals(ts.ResourceName, res.Name, StringComparisons.ResourceName) &&\n                !string.IsNullOrEmpty(ts.EndpointName) &&\n                !string.IsNullOrEmpty(ts.ContainerNetworkName)\n            );\n\n            foreach (var ts in tunnelServices)\n            {\n                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,","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Dcp/DcpModelUtilities.cs#L288-L324","documentation":"A container tunnel service reached endpoint-allocation without a complete address (AllocatedAddress/AllocatedPort), which should be guaranteed because the code waits for services to have complete addresses. This is an internal invariant check; hitting it means the tunnel's backing service never finished allocation.","triggerScenarios":"In AddContainerTunnelAllocatedEndpoints, ts.Service?.HasCompleteAddress is not true when processing tunnel services — the tunnel's DCP Service lacks a complete allocated address.","commonSituations":"Container/networking backends (docker, kind) failing to allocate ports; deleting or restarting the tunneled service mid-build; DCP races or bugs.","solutions":["Restart the AppHost so tunnel services re-allocate addresses.","Verify the container runtime and networks are healthy (docker ps / kind cluster status).","Update Aspire and file a bug if reproducible — the code marks this as an unreachable condition."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await appHost.StartAsync();\n}\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"tunnel service\") && ex.Message.Contains(\"should have valid address\"))\n{\n    // restart AppHost and container runtime; report upstream if persistent\n}","preventionTips":["Verify the container runtime is running and networks are healthy before large AppHosts.","Avoid stopping tunneled resources while endpoints are being allocated.","Update Aspire; this is an internal invariant check."],"tags":["aspire","dcp","tunnel","containers","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"}