{"record":{"id":"eb2946ab498b6666","repo":"owasp-amass/amass","slug":"string-parsing-failed","errorCode":null,"errorMessage":"String parsing failed","messagePattern":"String parsing failed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/parse.go","lineNumber":42,"sourceCode":"type ParseIPs []net.IP\n\n// ParseCIDRs implements the flag.Value interface.\ntype ParseCIDRs []*net.IPNet\n\n// ParseASNs implements the flag.Value interface.\ntype ParseASNs []int\n\nfunc (p *ParseStrings) String() string {\n\tif p == nil {\n\t\treturn \"\"\n\t}\n\treturn strings.Join(*p, \",\")\n}\n\n// Set implements the flag.Value interface.\nfunc (p *ParseStrings) Set(s string) error {\n\tif s == \"\" {\n\t\treturn fmt.Errorf(\"String parsing failed\")\n\t}\n\n\tstr := strings.Split(s, \",\")\n\tfor _, s := range str {\n\t\t*p = append(*p, strings.TrimSpace(s))\n\t}\n\treturn nil\n}\n\nfunc (p *ParseInts) String() string {\n\tif p == nil {\n\t\treturn \"\"\n\t}\n\tvar builder strings.Builder\n\tfor i, n := range *p {\n\t\tif i > 0 {\n\t\t\tbuilder.WriteRune(',')\n\t\t}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/parse.go#L24-L60","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nrun -domains \"$DOMAINS\"          # DOMAINS empty -> String parsing failed\n// after\nif [ -n \"$DOMAINS\" ]; then set -- \"$@\" -domains \"$DOMAINS\"; fi","handlingStrategy":"validation","validationCode":"func validateStringFlag(value string) error {\n\tif strings.TrimSpace(value) == \"\" {\n\t\treturn errors.New(\"flag requires a non-empty comma-separated string list\")\n\t}\n\tfor _, v := range strings.Split(value, \",\") {\n\t\tif strings.TrimSpace(v) == \"\" {\n\t\t\treturn fmt.Errorf(\"empty entry in list %q\", value)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isNonEmptyList(s string) bool { return strings.TrimSpace(s) != \"\" }","tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","flag-parsing","validation"],"backgroundTag":"invalid-flag-value","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}