shadow1ng/fscan · error
parser_cidr_failed: %w
Error message
parser_cidr_failed: %w
What it means
newHostSource fails when a host expression containing '/' looks like a CIDR but newCIDRHostSource cannot parse it, wrapping the parse error with an i18n message. It indicates malformed CIDR notation in the target specification.
Source
Thrown at common/parsers/host_iterator.go:307
return nil, err
}
sources = append(sources, src)
}
return sources, nil
}
func newHostSource(host string) (hostSource, error) {
switch {
case host == "192":
return newCIDRHostSource("192.168.0.0/16")
case host == "172":
return newCIDRHostSource("172.16.0.0/12")
case host == "10":
return newCIDRHostSource("10.0.0.0/8")
case strings.Contains(host, "/"):
src, err := newCIDRHostSource(host)
if err != nil {
return nil, fmt.Errorf(i18n.Tr("parser_cidr_failed", host)+": %w", err)
}
return src, nil
case strings.Contains(host, "-") && !strings.Contains(host, ":") && looksLikeIPRange(host):
src, err := newRangeHostSource(host)
if err != nil {
return nil, fmt.Errorf(i18n.Tr("parser_ip_range_failed", host)+": %w", err)
}
return src, nil
default:
return &singleHostSource{host: host}, nil
}
}
func newCIDRHostSource(cidr string) (hostSource, error) {
_, ipNet, err := net.ParseCIDR(cidr)
if err != nil {
return nil, err
}View on GitHub (pinned to 95cc12e753)
Solutions
- Correct the CIDR notation (valid base IP and prefix 0-32)
- Validate CIDR strings with net.ParseCIDR before passing them
- Split multiple targets and test each individually to locate the bad one
Example fix
// before
targets := []string{"192.168.1.0/33"}
// after
for _, t := range targets {
if _, _, err := net.ParseCIDR(t); err != nil { log.Fatalf("bad CIDR %s: %v", t, err) }
} Defensive patterns
Strategy: validation
Validate before calling
if strings.Contains(target, "/") {
if _, _, err := net.ParseCIDR(target); err != nil {
return fmt.Errorf("invalid CIDR %q: %w", target, err)
}
} Try / catch
srcs, err := newHostSources(targets)
if err != nil {
if strings.Contains(err.Error(), "parser_cidr_failed") {
log.Fatalf("fix CIDR notation: %v", err)
}
} Prevention
- Validate all target expressions with net.ParseCIDR/net.ParseIP up front
- Generate CIDRs programmatically instead of hand-writing them
- Trim whitespace and stray characters from targets
When it happens
Trigger: Passing targets like '192.168.1.0/33', 'abc/24', or '192.168.1.0/xx' where the prefix length or base address is invalid.
Common situations: Hand-written target lists with typos; copied CIDR with wrong prefix length; variable interpolation producing 'prefix/24' garbage.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- parser_ip_range_failed: %w
- parser_invalid_ip_end_val
- parser_invalid_ip_range_val
- portfinger_probe_name_invalid
- Parse error: first line must start with "Probe " or "Exclude
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/4fb422b2bcbb2784.
Report an issue: GitHub.