grafana/k6 · error

%s is not a valid IP, IP range or CIDR

Error message

%s is not a valid IP, IP range or CIDR

What it means

Raised by getIPBlock while building an IP pool (e.g. for external IP / ipBlock options): the string is neither parseable as a single IP (net.ParseIP fails) nor shaped like a range or CIDR, so no block can be constructed.

Source

Thrown at lib/types/ipblock.go:37

type ipPoolBlock struct {
	firstIP, startIndex *big.Int
}

// IPPool represent a slice of IPBlocks
type IPPool struct {
	list  []ipPoolBlock
	count *big.Int
}

func getIPBlock(s string) (*ipBlock, error) {
	switch {
	case strings.Contains(s, "-"):
		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)

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use a valid single IP (192.168.0.1), a range (192.168.0.0-192.168.0.255) or CIDR (192.168.0.0/24)
  2. Check for typos, stray characters or wrong IP version mixing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/types/ipblock.go:37 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/3123128caaeff6bd. Report an issue: GitHub.