{"record":{"id":"420d1a7dea3a9a79","repo":"apache/shardingsphere","slug":"unknown-argument-s","errorCode":null,"errorMessage":"Unknown argument: %s","messagePattern":"Unknown argument: (.+?)","errorType":"console","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"mcp/registry/src/main/java/org/apache/shardingsphere/mcp/registry/MCPRegistryMetadataCommand.java","lineNumber":137,"sourceCode":"                    break;\n                case \"--identifier\":\n                    identifier = readOptionValue(args, index + 1, \"--identifier\");\n                    index += 2;\n                    break;\n                case \"--dockerfile-path\":\n                    dockerfilePath = readOptionValue(args, index + 1, \"--dockerfile-path\");\n                    index += 2;\n                    break;\n                case \"--validate-only\":\n                    validateOnly = true;\n                    index++;\n                    break;\n                case \"--allow-snapshot\":\n                    allowSnapshot = true;\n                    index++;\n                    break;\n                default:\n                    throw new IllegalArgumentException(\"Unknown argument: \" + args[index]);\n            }\n        }\n        return new CommandOptions(path, version, identifier, dockerfilePath, validateOnly, allowSnapshot);\n    }\n    \n    private static String readOptionValue(final String[] args, final int index, final String optionName) {\n        ShardingSpherePreconditions.checkState(index < args.length && !args[index].startsWith(\"--\"),\n                () -> new IllegalArgumentException(optionName + \" requires a value.\"));\n        return args[index];\n    }\n    \n    private static void prepareServerJson(final Map<String, Object> server, final String version, final String identifier) {\n        server.put(\"version\", version);\n        for (Map<String, Object> each : getPackages(server)) {\n            each.put(\"identifier\", identifier);\n            each.put(\"version\", version);\n        }\n    }","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/mcp/registry/src/main/java/org/apache/shardingsphere/mcp/registry/MCPRegistryMetadataCommand.java#L119-L155","documentation":"Thrown while parsing command-line options in MCPRegistryMetadataCommand: the argument loop hit a token starting with a case label it does not recognize, so it rejects it with IllegalArgumentException('Unknown argument: ...'). This is strict CLI parsing — no positional or extra flags are tolerated.","triggerScenarios":"Running the registry metadata command with an unsupported flag (e.g. --output, --verbose) or a misspelled known option (--dockerfile_path instead of --dockerfile-path). Note option values are read positionally, so a missing value can also shift tokens into the flag position and produce this error.","commonSituations":"Copy-pasting options from other ShardingSphere CLI tools, version skew where an option was added/renamed, or forgetting that value options consume the next token (their value must not start with '--', enforced by readOptionValue).","solutions":["Remove or correct the offending flag; check the command's usage/help for the exact supported option set (--validate-only, --allow-snapshot, --dockerfile-path, etc. in this parser).","Ensure every value-taking option is followed by its value token so the parser does not misalign.","Re-run with only the documented options for your version of the registry command."],"exampleFix":"# before\n--dockerfile_path ./Dockerfile\n# after\n--dockerfile-path ./Dockerfile","handlingStrategy":"validation","validationCode":"Set<String> known = Set.of(\"--path\", \"--version\", \"--identifier\", \"--dockerfile-path\", \"--validate-only\", \"--allow-snapshot\");\nfor (int i = 0; i < args.length; i++) { if (args[i].startsWith(\"--\") && !known.contains(args[i])) throw new IllegalArgumentException(args[i]); }","typeGuard":null,"tryCatchPattern":"try {\n    MCPRegistryMetadataCommand.main(args);\n} catch (final IllegalArgumentException ex) {\n    // 'Unknown argument: X' -> print usage and exit 2; do not retry the same argv\n}","preventionTips":["Run the command's help/usage output before scripting new flags","Pin option spellings (kebab-case) in build scripts and CI","Remember value options consume the next token — never let values start with '--'"],"tags":["cli","registry","arguments","validation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}