{"record":{"id":"c123a9da18232773","repo":"muesli/duf","slug":"error-parsing-usage-threshold-invalid-option-s","errorCode":null,"errorMessage":"error parsing usage-threshold: invalid option '%s'","messagePattern":"error parsing usage-threshold: invalid option '(.+?)'","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":325,"sourceCode":"\n\t// validate availability thresholds\n\tavailbilityThresholds := strings.Split(*availThreshold, \",\")\n\tif len(availbilityThresholds) != 2 {\n\t\tfmt.Fprintln(os.Stderr, fmt.Errorf(\"error parsing avail-threshold: invalid option '%s'\", *availThreshold))\n\t\tos.Exit(1)\n\t}\n\tfor _, threshold := range availbilityThresholds {\n\t\t_, err = stringToSize(threshold)\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(os.Stderr, \"error parsing avail-threshold:\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\t// validate usage thresholds\n\tusageThresholds := strings.Split(*usageThreshold, \",\")\n\tif len(usageThresholds) != 2 {\n\t\tfmt.Fprintln(os.Stderr, fmt.Errorf(\"error parsing usage-threshold: invalid option '%s'\", *usageThreshold))\n\t\tos.Exit(1)\n\t}\n\tfor _, threshold := range usageThresholds {\n\t\t_, err = strconv.ParseFloat(threshold, 64)\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(os.Stderr, \"error parsing usage-threshold:\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\t// print out warnings\n\tif *warns {\n\t\tfor _, warning := range warnings {\n\t\t\tfmt.Fprintln(os.Stderr, warning)\n\t\t}\n\t}\n\n\t// detect terminal width","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/muesli/duf/blob/4636deb4a7b707a9f04c602db033f9837e50b3f6/main.go#L307-L343","documentation":"main validates the --usage-threshold flag, which must contain exactly two comma-separated numeric values (float percentages). If splitting on \",\" does not yield exactly two parts, the program prints \"error parsing usage-threshold: invalid option '%s'\" to stderr and exits with status 1.","triggerScenarios":"Running with --usage-threshold containing anything other than two comma-separated floats, e.g. \"80\", \"\", \"80,90,100\", or non-numeric tokens.","commonSituations":"Users pass a single percentage, separate values with spaces or semicolons instead of commas, or accidentally quote the flag value twice in shell.","solutions":["Supply exactly two comma-separated floats, e.g. --usage-threshold \"80,95\".","Remove stray characters/extra commas from the flag value.","Quote the argument in shell scripts to preserve the comma-separated format."],"exampleFix":"// before\n--usage-threshold 80\n// after\n--usage-threshold \"80,95\"","handlingStrategy":"validation","validationCode":"parts := strings.Split(usageThreshold, \",\")\nif len(parts) != 2 {\n\treturn fmt.Errorf(\"usage-threshold needs exactly 2 values\")\n}\nfor _, p := range parts {\n\tif _, err := strconv.ParseFloat(p, 64); err != nil { /* invalid */ }\n}","typeGuard":null,"tryCatchPattern":"if err := validateUsageThreshold(flag); err != nil {\n\tfmt.Fprintln(os.Stderr, err)\n\tos.Exit(1)\n}","preventionTips":["Always pass two comma-separated numbers like \"80,95\".","Quote the flag value in shell scripts.","Use plain floats without % signs or units."],"tags":["go","cli","validation","arguments"],"backgroundTag":"invalid-cli-argument","analyzedSha":"4636deb4a7b707a9f04c602db033f9837e50b3f6","analyzedAt":"2026-09-06T02:31:58.576Z","contentChangedAt":"2026-09-06T02:31:58.576Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}