{"record":{"id":"87d34fa4db6af478","repo":"muesli/duf","slug":"error-parsing-avail-threshold-invalid-option-s","errorCode":null,"errorMessage":"error parsing avail-threshold: invalid option '%s'","messagePattern":"error parsing avail-threshold: invalid option '(.+?)'","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":311,"sourceCode":"\t\t\t\tfmt.Println(err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t\t// de-duplicate\n\t\t\tfor _, v := range fm {\n\t\t\t\tif _, ok := vis[v.Mountpoint]; !ok {\n\t\t\t\t\tmounts = append(mounts, v)\n\t\t\t\t\tvis[v.Mountpoint] = struct{}{}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tm = mounts\n\t}\n\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)","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/muesli/duf/blob/4636deb4a7b707a9f04c602db033f9837e50b3f6/main.go#L293-L329","documentation":"main validates the --avail-threshold flag, which must contain exactly two comma-separated size values (e.g. \"10G,20G\"). If splitting on \",\" does not yield exactly two parts, the program prints \"error parsing avail-threshold: invalid option '%s'\" to stderr and exits with status 1.","triggerScenarios":"Running with --avail-threshold that has zero or one comma-separated part (e.g. \"10G\", \"\", \"10G,20G,30G\"), or an empty default flag value.","commonSituations":"Users pass a single threshold thinking one value suffices, include stray spaces or extra commas, or leave the flag empty in scripts.","solutions":["Supply exactly two comma-separated sizes, e.g. --avail-threshold \"10G,20G\".","Remove trailing/leading commas or spaces that create empty segments.","Quote the value in shell scripts so commas are not misinterpreted."],"exampleFix":"// before\n--avail-threshold 10G\n// after\n--avail-threshold \"10G,20G\"","handlingStrategy":"validation","validationCode":"parts := strings.Split(availThreshold, \",\")\nif len(parts) != 2 {\n\treturn fmt.Errorf(\"avail-threshold needs exactly 2 values\")\n}\nfor _, p := range parts {\n\tif _, err := regexp.MatchString(`^\\d+[KMGTPE]?$`, p); err != nil { /* invalid */ }\n}","typeGuard":null,"tryCatchPattern":"if err := validateAvailThreshold(flag); err != nil {\n\tfmt.Fprintln(os.Stderr, err)\n\tos.Exit(1)\n}","preventionTips":["Always pass two comma-separated sizes like \"10G,20G\".","Quote the flag value in shell scripts.","Avoid spaces and trailing commas in the value."],"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-14T05:17:10.506Z"}