{"record":{"id":"e88afdba4166bebe","repo":"grpc/grpc-go","slug":"endpoints-list-contains-no-addresses","errorCode":null,"errorMessage":"endpoints list contains no addresses","messagePattern":"endpoints list contains no addresses","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resolver/resolver.go","lineNumber":358,"sourceCode":"\t// necessary.\n\tOverrideAuthority(Target) string\n}\n\n// ValidateEndpoints validates endpoints from a petiole policy's perspective.\n// Petiole policies should call this before calling into their children. See\n// [gRPC A61](https://github.com/grpc/proposal/blob/master/A61-IPv4-IPv6-dualstack-backends.md)\n// for details.\nfunc ValidateEndpoints(endpoints []Endpoint) error {\n\tif len(endpoints) == 0 {\n\t\treturn errors.New(\"endpoints list is empty\")\n\t}\n\n\tfor _, endpoint := range endpoints {\n\t\tfor range endpoint.Addresses {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn errors.New(\"endpoints list contains no addresses\")\n}\n","sourceCodeStart":340,"sourceCodeEnd":360,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/resolver/resolver.go#L340-L360","documentation":"Returned by resolver.ValidateEndpoints (resolver/resolver.go:358) when the endpoints slice is non-empty but every endpoint has an empty Addresses slice. Having endpoints with no addresses is equivalent to having no usable backends, so the validator rejects it. The loop at lines 353-357 returns nil on the first non-empty Addresses it finds.","triggerScenarios":"A resolver produces Endpoint structs with metadata but no populated Addresses; an xDS update carries endpoint objects whose address list was stripped; a wrapper that copies endpoints but drops the inner addresses.","commonSituations":"Locality-weighted LB configs where all localities have zero weight/addresses; a bug in a custom resolver that fills Endpoint fields except Addresses; partial deserialization of a discovery response.","solutions":["Ensure each Endpoint you publish has at least one resolver.Address in its Addresses field.","Filter out empty-address endpoints before calling UpdateState/ValidateEndpoints.","Debug the resolver to confirm where the addresses are being dropped.","Fall back to a previous resolver state instead of pushing an all-empty update."],"exampleFix":"// before\neps := []resolver.Endpoint{{Addresses: nil}}\nresolver.ValidateEndpoints(eps) // error\n\n// after\nfor i := range eps {\n    if len(eps[i].Addresses) == 0 {\n        eps[i].Addresses = []resolver.Address{{Addr: addr}}\n    }\n}\nresolver.ValidateEndpoints(eps)","handlingStrategy":"validation","validationCode":"func anyAddresses(eps []resolver.Endpoint) bool {\n    for _, e := range eps {\n        if len(e.Addresses) > 0 { return true }\n    }\n    return false\n}\nif !anyAddresses(eps) { return errors.New(\"no addresses\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure each Endpoint carries at least one resolver.Address.","Filter out empty-address endpoints before publishing.","Unit test custom resolvers to confirm addresses are populated."],"tags":["go","grpc","resolver","load-balancing","service-discovery"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}