{"record":{"id":"9dc8c99e96e2f70f","repo":"urfave/cli","slug":"sufficient-count-of-arg-s-not-provided-given-d","errorCode":null,"errorMessage":"sufficient count of arg %s not provided, given %d expected %d","messagePattern":"sufficient count of arg (.+?) not provided, given (.+?) expected (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"args.go","lineNumber":229,"sourceCode":"\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\n\t\t}\n\t}\n\tif count < a.Min {\n\t\treturn s, fmt.Errorf(\"sufficient count of arg %s not provided, given %d expected %d\", a.Name, count, a.Min)\n\t}\n\n\tif a.Destination != nil {\n\t\ttracef(\"appending destination\")\n\t\t*a.Destination = a.values // append(*a.Destination, a.values...)\n\t}\n\n\treturn s[count:], nil\n}\n\nfunc (a *ArgumentsBase[T, C, VC]) Get() any {\n\tif a.values != nil {\n\t\treturn a.values\n\t}\n\treturn []T{}\n}\n\ntype (","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/args.go#L211-L247","documentation":"After consuming values, ArgumentsBase.Parse checks count < a.Min and returns this error naming the argument, how many values were given, and the required minimum. It means the user supplied too few values for a required positional argument.","triggerScenarios":"Invoking a command whose argument declares Min > 0 (e.g. cli.Args{Min: 2}) with fewer than Min tokens on the command line.","commonSituations":"Forgetting a required argument in scripts/CI invocations, shell quoting collapsing what should be two values into one, or an empty shell variable vanishing from the command line.","solutions":["Supply at least Min values on the command line: the message states exactly how many were given and expected.","Quote multi-word values individually so shell word-splitting preserves each argument.","Check for empty environment variables being dropped in scripted invocations; guard with \"${VAR:?}\"."],"exampleFix":"// before\nmyapp copy src/          # Min: 2\n// after\nmyapp copy src/ dst/","handlingStrategy":"validation","validationCode":"minRequired := 2\ngiven := len(positionalArgs)\nif given < minRequired {\n\treturn fmt.Errorf(\"need %d positional args, got %d\", minRequired, given)\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(ctx, os.Args); err != nil {\n\tif strings.Contains(err.Error(), \"sufficient count of arg\") {\n\t\tfmt.Fprintf(os.Stderr, \"usage error — too few arguments: %v\\n\", err)\n\t\tos.Exit(2)\n\t}\n\treturn err\n}","preventionTips":["Check argument count in wrapper scripts before invoking the CLI.","Quote each multi-word value individually so shell splitting preserves counts.","Guard empty env variables in scripts (${VAR:?}) so they don't silently drop arguments."],"tags":["go","cli","argument-parsing","usage"],"backgroundTag":"missing-required-argument","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}