{"record":{"id":"5d9968c8f08da772","repo":"golang-migrate/migrate","slug":"too-many-arguments","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/commands.go","lineNumber":246,"sourceCode":"\tif applyAll {\n\t\tif len(args) > 0 {\n\t\t\treturn 0, false, errors.New(\"-all cannot be used with other arguments\")\n\t\t}\n\t\treturn -1, false, nil\n\t}\n\n\tswitch len(args) {\n\tcase 0:\n\t\treturn -1, true, nil\n\tcase 1:\n\t\tdownValue := args[0]\n\t\tn, err := strconv.ParseUint(downValue, 10, 64)\n\t\tif err != nil {\n\t\t\treturn 0, false, errors.New(\"can't read limit argument N\")\n\t\t}\n\t\treturn int(n), false, nil\n\tdefault:\n\t\treturn 0, false, errors.New(\"too many arguments\")\n\t}\n}\n","sourceCodeStart":228,"sourceCodeEnd":249,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/internal/cli/commands.go#L228-L249","documentation":"numDownMigrationsFromArgs returns 'too many arguments' when `migrate down` receives more than one positional argument. The down command accepts at most a single limit N (or -all); anything else is ambiguous, so the CLI rejects it.","triggerScenarios":"Running `migrate down 1 2`, passing extra free-form arguments, or shell expansion inserting multiple words (unquoted variables, globs) after the subcommand.","commonSituations":"Users passing migration names/targets to down expecting v1-style behavior; unquoted $@ or glob expansion in scripts adding extra words; copy-pasted commands with stray tokens.","solutions":["Pass at most one positional argument: `migrate down N` or `migrate down -all`.","Quote variables in shell scripts and avoid forwarding $@ to the CLI.","Remove extra tokens such as migration filenames — down takes a count, not a target.","In wrapper scripts, validate the arg count before exec'ing migrate."],"exampleFix":"// before\nmigrate -path ./migrations -database $DB down $ARGS\n// after\nset -- $ARGS; if [ $# -gt 1 ]; then echo \"too many args\"; exit 1; fi\nmigrate -path ./migrations -database $DB down \"$@\"","handlingStrategy":"validation","validationCode":"if [ $# -gt 1 ]; then\n\techo \"migrate down accepts at most one argument\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote shell variables so they expand to a single word","Do not forward \"$@\" unfiltered to migrate down","Remember down takes only a count N or -all — no migration names/targets"],"tags":["go","cli","golang-migrate","invalid-argument"],"backgroundTag":"invalid-argument","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}