kubernetes/kops · error

unable to parse CIDR subnet string %q using %q

Error message

unable to parse CIDR subnet string %q using %q

What it means

Error "unable to parse CIDR subnet string %q using %q" thrown in kubernetes/kops.

Source

Thrown at upup/pkg/fi/utils/net.go:85

	if err != nil {
		return false
	}

	// Must NOT convert to IPv4
	if ip.To4() != nil {
		return false
	}

	return true
}

// ParseCIDRNotation parses a string in the format "/<newSize>#<netNum>"
// and returns the values of <newSize> and <netNum>.
func ParseCIDRNotation(subnet string) (int, int64, error) {
	re := regexp.MustCompile(`^/(\d+)#([a-f0-9]+)$`)
	s := re.FindStringSubmatch(subnet)
	if len(s) != 3 {
		return 0, 0, fmt.Errorf("unable to parse CIDR subnet string %q using %q", subnet, re)
	}

	newSize, err := strconv.Atoi(s[1])
	if err != nil {
		return 0, 0, fmt.Errorf("unable to convert CIDR subnet new bits to int: %q: %v", s[1], err)
	}

	netNum, err := strconv.ParseInt(s[2], 16, 64)
	if err != nil {
		return 0, 0, fmt.Errorf("unable to convert CIDR subnet net num to int: %q: %v", s[2], err)
	}

	return newSize, netNum, nil
}

// CIDRSubnet calculates a subnet address within given IP network address prefix.
// Inspired by the Terraform implementation of the "cidrsubnet" function
// https://www.terraform.io/docs/language/functions/cidrsubnet.html

View on GitHub (pinned to 4c8573c808)

When it happens

Trigger: Thrown at upup/pkg/fi/utils/net.go:85 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/1bf8589fe93eaeee. Report an issue: GitHub.