{"record":{"id":"342c1df34bfc1336","repo":"grafana/k6","slug":"mixed-ip-range-format-s","errorCode":null,"errorMessage":"mixed IP range format: %s","messagePattern":"mixed IP range format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/types/ipblock.go","lineNumber":50,"sourceCode":"\t\treturn ipBlockFromRange(s)\n\tcase strings.Contains(s, \"/\"):\n\t\treturn ipBlockFromCIDR(s)\n\tdefault:\n\t\tif net.ParseIP(s) == nil {\n\t\t\treturn nil, fmt.Errorf(\"%s is not a valid IP, IP range or CIDR\", s)\n\t\t}\n\t\treturn ipBlockFromRange(s + \"-\" + s)\n\t}\n}\n\nfunc ipBlockFromRange(s string) (*ipBlock, error) {\n\tip0Str, ip1Str, _ := strings.Cut(s, \"-\")\n\tip0, ip1 := net.ParseIP(ip0Str), net.ParseIP(ip1Str)\n\tif ip0 == nil || ip1 == nil {\n\t\treturn nil, errors.New(\"wrong IP range format: \" + s)\n\t}\n\tif (ip0.To4() == nil) != (ip1.To4() == nil) { // XOR\n\t\treturn nil, errors.New(\"mixed IP range format: \" + s)\n\t}\n\tblock := ipBlockFromTwoIPs(ip0, ip1)\n\n\tif block.count.Sign() <= 0 {\n\t\treturn nil, errors.New(\"negative IP range: \" + s)\n\t}\n\treturn block, nil\n}\n\nfunc ipBlockFromTwoIPs(ip0, ip1 net.IP) *ipBlock {\n\t// This code doesn't do any checks on the validity of the arguments, that should be\n\t// done before and/or after it is called\n\tvar block ipBlock\n\tblock.firstIP = new(big.Int)\n\tblock.count = new(big.Int)\n\tblock.ipv6 = ip0.To4() == nil\n\tif block.ipv6 {\n\t\tblock.firstIP.SetBytes(ip0.To16())","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/types/ipblock.go#L32-L68","documentation":"Raised by ipBlockFromRange when both ends of an IP range parse as IPs but one is IPv4 and the other IPv6 (the To4() XOR check). k6 cannot construct a contiguous range across address families.","triggerScenarios":"Thrown at lib/types/ipblock.go:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use two addresses from the same family, e.g. '192.168.0.1-192.168.0.10' or IPv6 counterparts","Define separate ranges for IPv4 and IPv6 addresses"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}