owasp-amass/amass · error
IP address parsing failed
Error message
IP address parsing failed
What it means
ParseIPs is a flag.Value implementation for comma-separated IP address/range flags. Set rejects an empty string with this error before doing any parsing. Non-empty input must consist of comma-separated entries each of which is a resolvable range, a parseable IP, or a CIDR.
Source
Thrown at internal/afmt/parse.go:100
func (p *ParseIPs) String() string {
if p == nil {
return ""
}
var builder strings.Builder
for i, ipaddr := range *p {
if i > 0 {
builder.WriteRune(',')
}
builder.WriteString(ipaddr.String())
}
return builder.String()
}
// Set implements the flag.Value interface.
func (p *ParseIPs) Set(s string) error {
if s == "" {
return fmt.Errorf("IP address parsing failed")
}
for _, v := range strings.Split(s, ",") {
if start, end, ok := parseRange(v); ok {
ips := amassnet.RangeHosts(start, end)
if len(ips) == 0 {
return fmt.Errorf("%s is not a valid IP address or range", v)
}
for _, ip := range ips {
*p = append(*p, ip)
}
continue
} else if ip := net.ParseIP(v); ip != nil {
*p = append(*p, ip)
continue
} else {
return fmt.Errorf("%s is not a valid IP address or range", v)
}View on GitHub (pinned to 79299dce87)
Solutions
- Provide a non-empty comma-separated value such as "192.168.1.1,10.0.0.0/24".
- Guard the variable in the shell (test -n) before invoking the command.
- Omit the flag entirely when no IPs are needed.
Example fix
// before -ip "$IPS" # IPS empty -> IP address parsing failed // after -ip "192.168.1.1,192.168.1.10-20,10.0.0.0/24"
Defensive patterns
Strategy: validation
Validate before calling
func validateIPsFlag(value string) error {
if strings.TrimSpace(value) == "" {
return errors.New("flag requires at least one IP, range, or CIDR")
}
for _, v := range strings.Split(value, ",") {
if net.ParseIP(strings.TrimSpace(v)) == nil && !strings.Contains(v, "-") && !strings.Contains(v, "/") {
return fmt.Errorf("entry %q is not an IP, range, or CIDR", v)
}
}
return nil
} Type guard
func isIPOrRange(s string) bool { return net.ParseIP(s) != nil || strings.ContainsAny(s, "-/") } Prevention
- Test shell variables for non-emptiness before passing them as flags.
- Omit the flag entirely rather than passing an empty string.
- Keep a validated IP inventory file and generate the flag from it.
When it happens
Trigger: Calling Set("") on a *ParseIPs, e.g. `-ip "$IP_LIST"` where IP_LIST is empty, or passing `-ip ""` in a script with an unset variable.
Common situations: Empty environment variables in scripts, CI templates with missing inputs, or mistaken attempts to clear a default flag value with an empty string.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- %s is not a valid IP address or range
- %s is not a valid CIDR
- failed to parse %s as a CIDR
- IP address parsing failed
- String parsing failed
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/8c48d05845fbd828.
Report an issue: GitHub.