{"record":{"id":"5a83afff0b28b736","repo":"cilium/cilium","slug":"failed-to-unmarshal-ip-address","errorCode":null,"errorMessage":"failed to unmarshal IP address","messagePattern":"failed to unmarshal IP address","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/datapath/linux/route/reconciler/table.go","lineNumber":108,"sourceCode":"\t\treturn fmt.Errorf(\"data too short to unmarshal DesiredRouteKey\")\n\t}\n\n\tif data[0] != byte(desiredRouteKeyBinaryVersion) {\n\t\treturn fmt.Errorf(\"unsupported DesiredRouteKey version: %d\", data[0])\n\t}\n\tdata = data[1:]\n\n\tk.Table = TableID(binary.LittleEndian.Uint32(data[0:4]))\n\tdata = data[4:]\n\n\taddrLen := int(data[0])\n\tdata = data[1:]\n\tif len(data) < addrLen+1+4 { // addr + 1 (prefix bits) + 4 (priority)\n\t\treturn fmt.Errorf(\"data too short to unmarshal DesiredRouteKey\")\n\t}\n\taddr, ok := netip.AddrFromSlice(data[0:addrLen])\n\tif !ok {\n\t\treturn fmt.Errorf(\"failed to unmarshal IP address\")\n\t}\n\tprefixBits := int(data[addrLen])\n\tk.Prefix = netip.PrefixFrom(addr, prefixBits)\n\tdata = data[addrLen+1:]\n\n\tk.Priority = binary.LittleEndian.Uint32(data[0:4])\n\n\treturn nil\n}\n\ntype NexthopInfo struct {\n\tDevice  *tables.Device\n\tNexthop netip.Addr\n}\n\nfunc (nh *NexthopInfo) String() string {\n\tif nh == nil {\n\t\treturn \"none\"","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/datapath/linux/route/reconciler/table.go#L90-L126","documentation":"After the length checks pass, the address bytes are converted with netip.AddrFromSlice; failure means the addrLen bytes are not a valid 4- or 16-byte IP address. The serialized key contains garbage in the address field.","triggerScenarios":"addrLen in the key data is corrupted or the bytes at data[0:addrLen] are not 4 or 16 bytes of a valid IP — netip.AddrFromSlice only accepts those lengths.","commonSituations":"Bit-rot or manual corruption of the WAL/state file; a writer bug producing wrong addrLen; deserializing non-key bytes.","solutions":["Delete and regenerate the corrupted state/WAL file","Confirm the writing side always marshals valid netip.Addr values (4 or 16 bytes)","Verify addrLen in the stream matches the actual address bytes present","Check for storage corruption on the node"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"addrLen := int(data[5])\nif addrLen != 4 && addrLen != 16 {\n    return fmt.Errorf(\"invalid addrLen %d in serialized key\", addrLen)\n}","typeGuard":"func hasValidAddrBytes(data []byte, addrLen int) bool {\n    if addrLen != 4 && addrLen != 16 { return false }\n    _, ok := netip.AddrFromSlice(data[0:addrLen])\n    return ok\n}","tryCatchPattern":"if err := k.UnmarshalBinary(data); err != nil {\n    if strings.Contains(err.Error(), \"unmarshal IP address\") {\n        log.Warn(\"corrupt address in key, discarding record\")\n        return nil\n    }\n    return err\n}","preventionTips":["Only marshal keys whose Addr comes from netip.ParseAddr with error handling","Add checksums to persisted key blobs","Reject invalid CIDRs at the user/config input layer"],"tags":["go","unmarshal","invalid-ip","netip","serialization"],"backgroundTag":"invalid-ip-address-data","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}