{"record":{"id":"35cdcab2ab453f87","repo":"cilium/cilium","slug":"invalid-ip-family-s-35cdca","errorCode":null,"errorMessage":"invalid IP family: %s","messagePattern":"invalid IP family: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ipam/metadata/manager.go","lineNumber":130,"sourceCode":"\t\t\treturn annotations[annotation.IPAMPoolKey], true\n\t\t}\n\tcase ipam.IPv6:\n\t\tif annotations[annotation.IPAMIPv6PoolKey] != \"\" {\n\t\t\treturn annotations[annotation.IPAMIPv6PoolKey], true\n\t\t} else if annotations[annotation.IPAMPoolKey] != \"\" {\n\t\t\treturn annotations[annotation.IPAMPoolKey], true\n\t\t}\n\t}\n\n\treturn \"\", false\n}\n\nfunc (m *manager) GetIPPoolForPod(owner string, family ipam.Family) (pool string, err error) {\n\tif !m.poolsSynced.Load() {\n\t\treturn \"\", ErrManagerPoolsNotSynced\n\t}\n\tif family != ipam.IPv6 && family != ipam.IPv4 {\n\t\treturn \"\", fmt.Errorf(\"invalid IP family: %s\", family)\n\t}\n\n\tnamespace, name, ok := splitK8sPodName(owner)\n\tif !ok {\n\t\tm.logger.Debug(\n\t\t\t\"pool selector: IPAM metadata request for invalid pod name, falling back to default pool\",\n\t\t\tlogfields.Owner, owner,\n\t\t)\n\t\treturn ipam.PoolDefault().String(), nil\n\t}\n\n\ttxn := m.db.ReadTxn()\n\n\t// Check annotation on pod\n\tpod, _, found := m.pods.Get(txn, k8sTables.PodByName(namespace, name))\n\tif !found {\n\t\treturn \"\", &ResourceNotFound{Resource: \"Pod\", Namespace: namespace, Name: name}\n\t} else if ippool, ok := determinePoolByAnnotations(pod.Annotations, family); ok {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/ipam/metadata/manager.go#L112-L148","documentation":"GetIPPoolForPod validates the requested address family before consulting pool selectors. If the family argument is neither ipam.IPv6 nor ipam.IPv4 (e.g. zero value or an unknown Family), the manager refuses to proceed because pool matching is family-scoped and an unknown family would produce wrong or empty matches.","triggerScenarios":"Calling GetIPPoolForPod(owner, family) with a Family value other than ipam.IPv4 or ipam.IPv6 — typically the zero value of ipam.Family (empty string) or a family derived from unparsed/unvalidated config or an address with no discernible family.","commonSituations":"A caller derives the family from a pod IP that failed to parse; config where --ipv4/--ipv6 are both disabled so family is never set; new Family constants added upstream but not handled here; unit tests passing an empty family accidentally.","solutions":["Pass an explicit ipam.IPv4 or ipam.IPv6 constant to GetIPPoolForPod","Derive the family via ipam.DeriveFamilyFromIP or equivalent on a successfully parsed net.IP","Check caller config: ensure IPv4 or IPv6 is actually enabled so a real family is computed","Add a switch over ipam.Family at the call site to catch unhandled values at compile/review time"],"exampleFix":"// before\npool, err := mgr.GetIPPoolForPod(podName, familyFromConfig) // family may be \"\"\n// after\nif familyFromConfig != ipam.IPv4 && familyFromConfig != ipam.IPv6 {\n    familyFromConfig = ipam.IPv4 // or derive from the pod IP\n}\npool, err := mgr.GetIPPoolForPod(podName, familyFromConfig)","handlingStrategy":"validation","validationCode":"if family != ipam.IPv4 && family != ipam.IPv6 {\n    return fmt.Errorf(\"caller bug: unsupported family %q\", family)\n}\npool, err := mgr.GetIPPoolForPod(owner, family)","typeGuard":"func validFamily(f ipam.Family) bool { return f == ipam.IPv4 || f == ipam.IPv6 }","tryCatchPattern":null,"preventionTips":["Always derive family with ipam.DeriveFamilyFromIP on a parsed pod IP","Never pass a raw config string cast to ipam.Family without validating","Add a default case in family switches to surface unhandled values"],"tags":["ipam","cilium","invalid-argument","address-family"],"backgroundTag":"invalid-ip-family","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}