grafana/k6 · error

mixed IP range format

Error message

mixed IP range format: %s

What it means

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.

Solutions

  1. Use two addresses from the same family, e.g. '192.168.0.1-192.168.0.10' or IPv6 counterparts
  2. Define separate ranges for IPv4 and IPv6 addresses
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/types/ipblock.go:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/342c1df34bfc1336. Report an issue: GitHub.

Appendix: source

Thrown at lib/types/ipblock.go:50

		return ipBlockFromRange(s)
	case strings.Contains(s, "/"):
		return ipBlockFromCIDR(s)
	default:
		if net.ParseIP(s) == nil {
			return nil, fmt.Errorf("%s is not a valid IP, IP range or CIDR", s)
		}
		return ipBlockFromRange(s + "-" + s)
	}
}

func ipBlockFromRange(s string) (*ipBlock, error) {
	ip0Str, ip1Str, _ := strings.Cut(s, "-")
	ip0, ip1 := net.ParseIP(ip0Str), net.ParseIP(ip1Str)
	if ip0 == nil || ip1 == nil {
		return nil, errors.New("wrong IP range format: " + s)
	}
	if (ip0.To4() == nil) != (ip1.To4() == nil) { // XOR
		return nil, errors.New("mixed IP range format: " + s)
	}
	block := ipBlockFromTwoIPs(ip0, ip1)

	if block.count.Sign() <= 0 {
		return nil, errors.New("negative IP range: " + s)
	}
	return block, nil
}

func ipBlockFromTwoIPs(ip0, ip1 net.IP) *ipBlock {
	// This code doesn't do any checks on the validity of the arguments, that should be
	// done before and/or after it is called
	var block ipBlock
	block.firstIP = new(big.Int)
	block.count = new(big.Int)
	block.ipv6 = ip0.To4() == nil
	if block.ipv6 {
		block.firstIP.SetBytes(ip0.To16())

View on GitHub (pinned to 01ffac6f24)