{"record":{"id":"b866c1e1b1d71e0e","repo":"cilium/cilium","slug":"invalid-ip-address-w","errorCode":null,"errorMessage":"invalid IP address: %w","messagePattern":"invalid IP address: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/datapath/neighbor/desired_neighbor.go","lineNumber":60,"sourceCode":"}\n\nfunc (dn DesiredNeighborKey) TableKey() index.Key {\n\treturn append(index.Int(dn.IfIndex), index.NetIPAddr(dn.IP)...)\n}\n\nfunc (dn *DesiredNeighborKey) String() string {\n\treturn fmt.Sprintf(\"%s@%d\", dn.IP.String(), dn.IfIndex)\n}\n\nfunc desiredNeighborKeyFromString(s string) (index.Key, error) {\n\tipStr, ifIndexStr, ok := strings.Cut(s, \"@\")\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid key format: '%s' expected {ip}@{ifindex}\", s)\n\t}\n\n\tip, err := index.NetIPAddrString(ipStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid IP address: %w\", err)\n\t}\n\n\tifIndex, err := index.IntString(ifIndexStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid interface index: %w\", err)\n\t}\n\n\treturn append(ifIndex, ip...), nil\n}\n\nfunc (dn *DesiredNeighbor) TableHeader() []string {\n\treturn []string{\n\t\t\"IP\",\n\t\t\"Link\",\n\t\t\"Status\",\n\t}\n}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/datapath/neighbor/desired_neighbor.go#L42-L78","documentation":"After splitting on '@', the IP portion is validated with index.NetIPAddrString; an unparseable or invalid IP yields this wrapped error. It protects the neighbor map from keys containing malformed addresses.","triggerScenarios":"desiredNeighborKeyFromString called with '{bad-ip}@<ifindex>' where bad-ip fails net.ParseIP/IPAddr parsing — e.g. empty string, hostname, or truncated IPv6.","commonSituations":"Hand-written keys using hostnames instead of IPs; locale/typo errors; parsing outputs where extra characters got glued to the IP (ports, zone specifiers).","solutions":["Correct the IP portion to a valid dotted-quad or IPv6 literal, e.g. 192.168.1.10@3 or fd00::a@3","Strip any port/zone suffixes before passing the string","Build the key programmatically from a net.IP via DesiredNeighborKey to avoid string mistakes"],"exampleFix":"// before\nkey, err := desiredNeighborKeyFromString(\"host.example@3\")\n// after\nkey, err := desiredNeighborKeyFromString(\"192.168.1.10@3\")","handlingStrategy":"validation","validationCode":"func validIPPortion(s string) bool { a, _, ok := strings.Cut(s, \"@\"); return ok && net.ParseIP(a) != nil }","typeGuard":null,"tryCatchPattern":"if net.ParseIP(ipStr) == nil { log.Warnf(\"bad IP in neighbor key %q\", s); return nil }","preventionTips":["Strip ports/zones from IP strings before key construction","Use net.IPNet/net.IP objects rather than raw strings when composing keys","Add unit tests for malformed IP inputs to the key parser"],"tags":["neighbor","parsing","ip-validation","datapath"],"backgroundTag":"invalid-ip-address","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}