grafana/k6 · error
failed to parse CIDR '%s': %w
Error message
failed to parse CIDR '%s': %w
What it means
Raised by IPNet.UnmarshalText while parsing a blocked hostnames/IP entry: the value is not valid CIDR notation, and the underlying parsing error is wrapped with %w. This feeds the hosts/blockHostnames options.
Source
Thrown at lib/options.go:205
return nil, err
}
key = pem.EncodeToMemory(&pem.Block{
Type: blockType,
Bytes: decryptedKey,
})
return key, nil
}
// IPNet is a wrapper around net.IPNet for JSON unmarshalling
type IPNet struct {
net.IPNet
}
// UnmarshalText populates the IPNet from the given CIDR
func (ipnet *IPNet) UnmarshalText(b []byte) error {
newIPNet, err := ParseCIDR(string(b))
if err != nil {
return fmt.Errorf("failed to parse CIDR '%s': %w", string(b), err)
}
*ipnet = *newIPNet
return nil
}
// MarshalText encodes the IPNet representation using CIDR notation.
func (ipnet *IPNet) MarshalText() ([]byte, error) {
return []byte(ipnet.String()), nil
}
// ParseCIDR creates an IPNet out of a CIDR string
func ParseCIDR(s string) (*IPNet, error) {
_, ipnet, err := net.ParseCIDR(s)
if err != nil {
return nil, err
}
View on GitHub (pinned to 01ffac6f24)
Solutions
- Provide a valid CIDR such as 10.0.0.0/8
- For single IPs, use the address with a /32 (IPv4) or /128 (IPv6) suffix or a plain IP form accepted by the parser
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/options.go:205 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/e668d0f4fc9532ae.
Report an issue: GitHub.