{"record":{"id":"9e37bb3a2a811bcc","repo":"urfave/cli","slug":"args-s-has-min-d-max-d-not-parsing-argumen","errorCode":null,"errorMessage":"args %s has min[%d] > max[%d], not parsing argument","messagePattern":"args (.+?) has min\\[(.+?)\\] > max\\[(.+?)\\], not parsing argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"args.go","lineNumber":207,"sourceCode":"\tif a.Min == 0 {\n\t\tif a.Max == 1 {\n\t\t\tusageFormat = \"[%[1]s]\"\n\t\t} else {\n\t\t\tusageFormat = \"[%[1]s ...]\"\n\t\t}\n\t} else {\n\t\tusageFormat = \"%[1]s [%[1]s ...]\"\n\t}\n\treturn fmt.Sprintf(usageFormat, a.Name)\n}\n\nfunc (a *ArgumentsBase[T, C, VC]) Parse(s []string) ([]string, error) {\n\ttracef(\"calling arg%[1] parse with args %[2]\", &a.Name, s)\n\tif a.Max == 0 {\n\t\treturn s, fmt.Errorf(\"args %s has max 0, not parsing argument\", a.Name)\n\t}\n\tif a.Max != -1 && a.Min > a.Max {\n\t\treturn s, fmt.Errorf(\"args %s has min[%d] > max[%d], not parsing argument\", a.Name, a.Min, a.Max)\n\t}\n\n\tcount := 0\n\tvar vc VC\n\tvar t T\n\tvalue := vc.Create(a.Value, &t, a.Config)\n\ta.values = []T{}\n\n\ttracef(\"attempting arg%[1] parse\", &a.Name)\n\tfor _, arg := range s {\n\t\tif err := value.Set(arg); err != nil {\n\t\t\treturn s, fmt.Errorf(\"invalid value %q for argument %s: %v\", arg, a.Name, err)\n\t\t}\n\t\ttracef(\"set arg%[1] one value\", &a.Name, value.Get().(T))\n\t\ta.values = append(a.values, value.Get().(T))\n\t\tcount++\n\t\tif count >= a.Max && a.Max > -1 {\n\t\t\tbreak","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/args.go#L189-L225","documentation":"ArgumentsBase.Parse validates Min <= Max and returns this error when the declared minimum number of values exceeds the maximum. Like the Max==0 case, it is a fail-fast check on the argument's own configuration, reported before any command-line values are consumed.","triggerScenarios":"Declaring an argument with Min greater than Max (and Max != -1), e.g. cli.Args{Min: 3, Max: 2}, then parsing any command line for that command.","commonSituations":"Copy-paste edits of Args definitions, refactors that lowered Max without lowering Min, or computing Min/Max dynamically where Min is derived larger than Max.","solutions":["Fix the definition so Min <= Max (e.g. swap or lower Min, or raise Max).","Use Max: -1 for unbounded arguments when an upper limit is not intended.","Add a sanity check or unit test for dynamically computed Min/Max values."],"exampleFix":"// before\nArgs: cli.Args{Min: 3, Max: 2}\n// after\nArgs: cli.Args{Min: 2, Max: 3}","handlingStrategy":"validation","validationCode":"func argsOK(a cli.Args) bool {\n\treturn a.Max == -1 || a.Min <= a.Max\n}\n// call on every Args definition before building the command","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(ctx, os.Args); err != nil {\n\tif strings.Contains(err.Error(), \"has min[\") {\n\t\treturn fmt.Errorf(\"argument misconfigured: Min exceeds Max: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Keep Min <= Max in every Args definition; use Max: -1 for unbounded.","Guard dynamically computed Min/Max with an assertion or unit test.","Re-check Args definitions after refactors that change limits."],"tags":["go","cli","argument-parsing","configuration"],"backgroundTag":"invalid-flag-arity","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}