owasp-amass/amass · error
String parsing failed
Error message
String parsing failed
What it means
ParseStrings is a flag.Value implementation that accepts a comma-separated list of strings for a CLI flag. Its Set method returns this error when the flag value is an empty string, since an empty input cannot be meaningfully split into list entries. It is an upfront guard so the resulting []string is only ever populated from real values.
Source
Thrown at internal/afmt/parse.go:42
type ParseIPs []net.IP
// ParseCIDRs implements the flag.Value interface.
type ParseCIDRs []*net.IPNet
// ParseASNs implements the flag.Value interface.
type ParseASNs []int
func (p *ParseStrings) String() string {
if p == nil {
return ""
}
return strings.Join(*p, ",")
}
// Set implements the flag.Value interface.
func (p *ParseStrings) Set(s string) error {
if s == "" {
return fmt.Errorf("String parsing failed")
}
str := strings.Split(s, ",")
for _, s := range str {
*p = append(*p, strings.TrimSpace(s))
}
return nil
}
func (p *ParseInts) String() string {
if p == nil {
return ""
}
var builder strings.Builder
for i, n := range *p {
if i > 0 {
builder.WriteRune(',')
}View on GitHub (pinned to 79299dce87)
Solutions
- Check that the value feeding the flag is non-empty before invoking the command.
- Pass actual comma-separated values, e.g. `-flag a,b,c`, instead of an empty string.
- Omit the flag entirely if no values are intended.
Example fix
// before run -domains "$DOMAINS" # DOMAINS empty -> String parsing failed // after if [ -n "$DOMAINS" ]; then set -- "$@" -domains "$DOMAINS"; fi
Defensive patterns
Strategy: validation
Validate before calling
func validateStringFlag(value string) error {
if strings.TrimSpace(value) == "" {
return errors.New("flag requires a non-empty comma-separated string list")
}
for _, v := range strings.Split(value, ",") {
if strings.TrimSpace(v) == "" {
return fmt.Errorf("empty entry in list %q", value)
}
}
return nil
} Type guard
func isNonEmptyList(s string) bool { return strings.TrimSpace(s) != "" } Prevention
- Skip appending flags whose value is empty when building commands programmatically.
- Use ${VAR:-default} shell expansion to avoid empty flag values.
- Trim and validate inputs before joining them with commas.
When it happens
Trigger: Calling Set("") on a *ParseStrings — occurs when the user runs the command with a flag given an empty value, e.g. `-domains ""`, or a script passes an empty shell variable as the flag argument.
Common situations: Shell variables that expand to empty (`-flag "$MY_LIST"` with MY_LIST unset), templated CI invocations with unfilled placeholders, or attempts to 'reset' a flag by passing 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
- integer parsing failed
- %s is not a valid IP address or range
- IP address parsing failed
- IP address parsing failed
- %s is not a valid CIDR
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/eb2946ab498b6666.
Report an issue: GitHub.