{"record":{"id":"ff12e26e6b517fcd","repo":"t8y2/dbx","slug":"unexpected-argument","errorCode":null,"errorMessage":"Unexpected argument: ","messagePattern":"Unexpected argument: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugins/jdbc/src/main/java/app/dbx/jdbc/maven/DbxMavenResolver.java","lineNumber":159,"sourceCode":"        private static ResolverOptions parse(String[] args) {\n            ResolverOptions options = new ResolverOptions();\n            for (int index = 0; index < args.length; index++) {\n                String arg = args[index];\n                switch (arg) {\n                    case \"resolve\" -> {\n                    }\n                    case \"--coordinate\", \"-c\" -> options.coordinate = value(args, ++index, arg);\n                    case \"--scope\" -> options.scope = value(args, ++index, arg).toLowerCase(Locale.ROOT);\n                    case \"--repo\", \"--repository\" -> options.repositories.add(value(args, ++index, arg));\n                    case \"--local-repo\" -> options.localRepository = Path.of(value(args, ++index, arg));\n                    default -> {\n                        if (arg.startsWith(\"-\")) {\n                            throw new IllegalArgumentException(\"Unsupported option: \" + arg);\n                        }\n                        if (options.coordinate == null) {\n                            options.coordinate = arg;\n                        } else {\n                            throw new IllegalArgumentException(\"Unexpected argument: \" + arg);\n                        }\n                    }\n                }\n            }\n            if (options.repositories.isEmpty()) {\n                options.repositories.add(DEFAULT_REPOSITORY);\n            }\n            return options;\n        }\n\n        private static String value(String[] args, int index, String option) {\n            if (index >= args.length || args[index].isBlank()) {\n                throw new IllegalArgumentException(option + \" requires a value\");\n            }\n            return args[index];\n        }\n    }\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/plugins/jdbc/src/main/java/app/dbx/jdbc/maven/DbxMavenResolver.java#L141-L177","documentation":"parse throws IllegalArgumentException when more than one non-flag positional argument is supplied. Only the first bare argument is taken as the Maven coordinate; a second bare token has no meaning and is rejected.","triggerScenarios":"Passing two positional values, e.g. 'com.example:foo:1.0 1.2' or forgetting a flag so an intended option value becomes a second positional argument (e.g. 'foo:1.0 com.example:bar:2.0' where the first coordinate was meant to follow --repo).","commonSituations":"Unquoted values containing spaces; missing a flag so a value like a repository URL is treated as a coordinate; copy-paste of two artifacts into one command.","solutions":["Provide exactly one coordinate argument; quote values containing spaces","Prefix the second value with its flag, e.g. --repo <url> or --coordinate <g:a:v>","Wrap values with spaces in quotes so they parse as a single argument"],"exampleFix":"// before\nDbxMavenResolver com.example:foo:1.0 https://repo.example.com/maven2\n// after\nDbxMavenResolver --repo https://repo.example.com/maven2 com.example:foo:1.0","handlingStrategy":"validation","validationCode":"long positionals = Arrays.stream(args).filter(a -> !a.startsWith(\"-\")).count();\nif (positionals > 1) {\n    throw new IllegalArgumentException(\"only one coordinate positional allowed\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Options o = Options.parse(args);\n} catch (IllegalArgumentException e) {\n    System.err.println(\"Usage: resolver [--repo URL] <group:artifact:version>\");\n    System.exit(2);\n}","preventionTips":["Pass exactly one coordinate as positional","Always use flags for non-coordinate values","Quote args containing spaces"],"tags":["cli","argument-parsing","too-many-arguments"],"backgroundTag":"invalid-cli-flag","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}