{"record":{"id":"f2cb90c597574beb","repo":"owasp-amass/amass","slug":"integer-parsing-failed","errorCode":null,"errorMessage":"integer parsing failed","messagePattern":"integer parsing failed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/parse.go","lineNumber":69,"sourceCode":"\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}\n\t\tbuilder.WriteString(strconv.Itoa(n))\n\t}\n\treturn builder.String()\n}\n\n// Set implements the flag.Value interface.\nfunc (p *ParseInts) Set(s string) error {\n\tif s == \"\" {\n\t\treturn fmt.Errorf(\"integer parsing failed\")\n\t}\n\n\tnums := strings.Split(s, \",\")\n\tfor _, n := range nums {\n\t\ti, err := strconv.Atoi(strings.TrimSpace(n))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*p = append(*p, i)\n\t}\n\treturn nil\n}\n\nfunc (p *ParseIPs) String() string {\n\tif p == nil {\n\t\treturn \"\"\n\t}\n\tvar builder strings.Builder","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/parse.go#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n-ports \"80,8443-8444\"    // integer parsing failed (range token)\n// after\n-ports \"80,8443\"         // enumerate each port explicitly","handlingStrategy":"validation","validationCode":"func validateIntsFlag(value string) error {\n\tif strings.TrimSpace(value) == \"\" {\n\t\treturn errors.New(\"flag requires a non-empty integer list\")\n\t}\n\tfor _, n := range strings.Split(value, \",\") {\n\t\tif _, err := strconv.Atoi(strings.TrimSpace(n)); err != nil {\n\t\t\treturn fmt.Errorf(\"token %q is not an integer\", n)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isIntList(s string) bool {\n\tfor _, n := range strings.Split(s, \",\") {\n\t\tif _, err := strconv.Atoi(strings.TrimSpace(n)); err != nil { return false }\n\t}\n\treturn strings.TrimSpace(s) != \"\"\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","flag-parsing","integer","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"}