owasp-amass/amass · error
integer parsing failed
Error message
integer parsing failed
What it means
ParseInts is a flag.Value implementation for comma-separated integer list flags. Set first rejects an empty string with this error, then parses each comma-separated token with strconv.Atoi; any token that is not a plain integer aborts the whole flag, guaranteeing the resulting []int contains only valid values.
Source
Thrown at internal/afmt/parse.go:69
func (p *ParseInts) String() string {
if p == nil {
return ""
}
var builder strings.Builder
for i, n := range *p {
if i > 0 {
builder.WriteRune(',')
}
builder.WriteString(strconv.Itoa(n))
}
return builder.String()
}
// Set implements the flag.Value interface.
func (p *ParseInts) Set(s string) error {
if s == "" {
return fmt.Errorf("integer parsing failed")
}
nums := strings.Split(s, ",")
for _, n := range nums {
i, err := strconv.Atoi(strings.TrimSpace(n))
if err != nil {
return err
}
*p = append(*p, i)
}
return nil
}
func (p *ParseIPs) String() string {
if p == nil {
return ""
}
var builder strings.BuilderView on GitHub (pinned to 79299dce87)
Solutions
- Ensure the value is non-empty and every comma-separated token is a plain integer, e.g. "80,443,8080".
- Remove range tokens ("1-100"); enumerate each integer explicitly.
- Verify the shell variable feeding the flag is set before invocation.
Example fix
// before -ports "80,8443-8444" // integer parsing failed (range token) // after -ports "80,8443" // enumerate each port explicitly
Defensive patterns
Strategy: validation
Validate before calling
func validateIntsFlag(value string) error {
if strings.TrimSpace(value) == "" {
return errors.New("flag requires a non-empty integer list")
}
for _, n := range strings.Split(value, ",") {
if _, err := strconv.Atoi(strings.TrimSpace(n)); err != nil {
return fmt.Errorf("token %q is not an integer", n)
}
}
return nil
} Type guard
func isIntList(s string) bool {
for _, n := range strings.Split(s, ",") {
if _, err := strconv.Atoi(strings.TrimSpace(n)); err != nil { return false }
}
return strings.TrimSpace(s) != ""
} Prevention
- Pre-validate the list with strconv.Atoi per token before invoking the tool.
- Never use range notation ("1-100") in integer list flags; enumerate values.
- Avoid unquoted shell variables that may expand to empty.
When it happens
Trigger: Calling Set("") on a *ParseInts (empty flag value), or any non-empty input where a token fails strconv.Atoi after trimming: "80,abc,443", range tokens like "1-100", tokens with stray characters, or integers out of int range.
Common situations: Port lists written with ranges ("8443-8444") which this parser does not expand, empty environment variables in scripts, copy-paste with extra whitespace or punctuation.
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
- String parsing failed
- %s is not a valid IP address or range
- ASN parsing failed
- IP address parsing failed
- IP address parsing failed
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/f2cb90c597574beb.
Report an issue: GitHub.