{"record":{"id":"2b00c3cdaee8fc97","repo":"urfave/cli","slug":"invalid-value-q-for-argument-s-v","errorCode":null,"errorMessage":"invalid value %q for argument %s: %v","messagePattern":"invalid value %q for argument (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"args.go","lineNumber":142,"sourceCode":"\treturn fmt.Sprintf(usageFormat, a.Name)\n}\n\nfunc (a *ArgumentBase[T, C, VC]) Parse(s []string) ([]string, error) {\n\ttracef(\"calling arg%[1] parse with args %[2]\", a.Name, s)\n\n\tif a.Required && len(s) == 0 {\n\t\treturn s, &errRequiredArguments{missingArguments: []string{a.Name}}\n\t}\n\n\tvar vc VC\n\tvar t T\n\tvalue := vc.Create(a.Value, &t, a.Config)\n\ta.value = &t\n\n\ttracef(\"attempting arg%[1] parse\", &a.Name)\n\tif len(s) > 0 {\n\t\tif err := value.Set(s[0]); err != nil {\n\t\t\treturn s, fmt.Errorf(\"invalid value %q for argument %s: %v\", s[0], a.Name, err)\n\t\t}\n\t\t*a.value = value.Get().(T)\n\t\ttracef(\"set arg%[1] one value\", a.Name, *a.value)\n\t}\n\n\tif a.Destination != nil {\n\t\ttracef(\"setting destination\")\n\t\t*a.Destination = *a.value\n\t}\n\n\tif len(s) > 0 {\n\t\treturn s[1:], nil\n\t}\n\treturn s, nil\n}\n\nfunc (a *ArgumentBase[T, C, VC]) Get() any {\n\tif a.value != nil {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/args.go#L124-L160","documentation":"During single-value argument parsing, ArgumentsBase.Parse calls the argument's value.Set with the raw string; if that fails, the error is wrapped as fmt.Errorf(\"invalid value %q for argument %s: %v\", ...). It reports which argument name failed, the offending raw value, and the underlying parse error, so it indicates bad input for that positional argument.","triggerScenarios":"Parsing a command line where a positional argument of a typed (e.g. IntFlag-like/Float/Duration) argument receives a value that value.Set cannot convert, e.g. an int argument given \"abc\" or an out-of-range number like \"99999999999999999999\".","commonSituations":"Users passing non-numeric values to numeric args, copy-paste errors, or values with units (\"10s\" for an int, \"1,000\" with a comma).","solutions":["Pass a value matching the argument's declared type (e.g. plain integer for an int argument).","Read the wrapped %v cause in the message — it names the actual parse failure (e.g. strconv.Atoi syntax error).","Loosen the argument to a string type and validate/convert yourself if flexible input is needed."],"exampleFix":"// before\nmyapp count abc\n// after\nmyapp count 42","handlingStrategy":"validation","validationCode":"func isParsableInt(s string) bool {\n\t_, err := strconv.Atoi(s)\n\treturn err == nil\n}\n// validate each positional arg before invoking the command","typeGuard":null,"tryCatchPattern":"err := cmd.Run(ctx, os.Args)\nvar invErr error\nif errors.As(err, &invErr) && strings.Contains(err.Error(), \"invalid value\") && strings.Contains(err.Error(), \"for argument\") {\n\tfmt.Fprintf(os.Stderr, \"check positional argument values: %v\\n\", err)\n\tos.Exit(2)\n}","preventionTips":["Match each positional argument to the declared type (int, float, duration...).","Strip units/ thousands separators before passing numeric values.","Read the wrapped cause (%v) to identify the exact conversion failure."],"tags":["go","cli","argument-parsing","type-conversion"],"backgroundTag":"invalid-argument-value","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}