{"record":{"id":"7efdc3502f6a21cd","repo":"grafana/k6","slug":"parsecidr-failed-parsing-s-w","errorCode":null,"errorMessage":"parseCIDR() failed parsing %s: %w","messagePattern":"parseCIDR\\(\\) failed parsing (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/types/ipblock.go","lineNumber":83,"sourceCode":"\tblock.count = new(big.Int)\n\tblock.ipv6 = ip0.To4() == nil\n\tif block.ipv6 {\n\t\tblock.firstIP.SetBytes(ip0.To16())\n\t\tblock.count.SetBytes(ip1.To16())\n\t} else {\n\t\tblock.firstIP.SetBytes(ip0.To4())\n\t\tblock.count.SetBytes(ip1.To4())\n\t}\n\tblock.count.Sub(block.count, block.firstIP)\n\tblock.count.Add(block.count, big.NewInt(1))\n\n\treturn &block\n}\n\nfunc ipBlockFromCIDR(s string) (*ipBlock, error) {\n\t_, pnet, err := net.ParseCIDR(s)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parseCIDR() failed parsing %s: %w\", s, err)\n\t}\n\tip0 := pnet.IP\n\t// TODO: this is just to copy it, it will probably be better to copy the bytes ...\n\tip1 := net.ParseIP(ip0.String())\n\tif ip1.To4() == nil {\n\t\tip1 = ip1.To16()\n\t} else {\n\t\tip1 = ip1.To4()\n\t}\n\tfor i := range ip1 {\n\t\tip1[i] |= (255 ^ pnet.Mask[i])\n\t}\n\tblock := ipBlockFromTwoIPs(ip0, ip1)\n\t// in the case of ipv4 if the network is bigger than 31 the first and last IP are reserved so we\n\t// need to reduce the addresses by 2 and increment the first ip\n\tif !block.ipv6 && big.NewInt(2).Cmp(block.count) < 0 {\n\t\tblock.count.Sub(block.count, big.NewInt(2))\n\t\tblock.firstIP.Add(block.firstIP, big.NewInt(1))","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/types/ipblock.go#L65-L101","documentation":"Raised by ipBlockFromCIDR when net.ParseCIDR rejects the CIDR string; the underlying Go error is wrapped with %w. Reached only when the input contains '/' but is not well-formed CIDR notation.","triggerScenarios":"Thrown at lib/types/ipblock.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use correct CIDR notation such as 10.0.0.0/8 or 2001:db8::/32","Ensure the prefix length is valid for the IP version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}