{"record":{"id":"233e1f15aa0209ed","repo":"NationalSecurityAgency/ghidra","slug":"missing-username","errorCode":null,"errorMessage":"Missing username","messagePattern":"Missing username","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":966,"sourceCode":"\t\t\tthrow new IllegalArgumentException(\"Missing data directory\");\n\t\t}\n\t\tdataDirectory = new File(params[slot]);\n\t\tif (!dataDirectory.isDirectory()) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Data directory \" + dataDirectory.getAbsolutePath() + \" does not exist\");\n\t\t}\n\t\tdataDirectory = dataDirectory.getCanonicalFile();\n\t}\n\n\t/**\n\t * Scan the username from the command-line\n\t * @param params are the command-line arguments\n\t * @param slot is the position to retrieve the username argument\n\t * @throws IllegalArgumentException if the user name is not in the given params\n\t */\n\tprivate void scanUsername(String[] params, int slot) throws IllegalArgumentException {\n\t\tif (params.length <= slot) {\n\t\t\tthrow new IllegalArgumentException(\"Missing username\");\n\t\t}\n\t\tspecifiedUserName = params[slot];\n\t}\n\n\t/**\n\t * Scan command-line for a particular privilege level. Administrator privileges are\n\t * requested with the exact String \"admin\", anything is a request for a read-only user \n\t * @param params are the command-line arguments\n\t * @param slot is the position to retrieve the user name argument\n\t * @throws IllegalArgumentException the privilege parameter is missing\n\t */\n\tprivate void scanPrivilege(String[] params, int slot) throws IllegalArgumentException {\n\t\tif (params.length <= slot) {\n\t\t\tthrow new IllegalArgumentException(\"Missing desired privilege (admin or user)\");\n\t\t}\n\t\tif (params[slot].equals(\"admin\")) {\n\t\t\tadminPrivilegeRequested = true;\n\t\t}","sourceCodeStart":948,"sourceCodeEnd":984,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L948-L984","documentation":"Thrown by scanUsername(params, slot) when the positional username argument is missing for adduser/dropuser/changeprivilege/resetpassword commands. These commands operate on a specific database role, so the name is mandatory.","triggerScenarios":"Running `bsim_ctl adduser [options]` without the trailing username argument, i.e. params.length <= slot.","commonSituations":"Forgot the username positional; option value consumed the slot unexpectedly; copy-paste from a partial example.","solutions":["Provide the username as the trailing positional argument, e.g. `bsim_ctl adduser [opts] <username>`.","Re-check argument ordering against the command usage.","For PKI adduser, also supply `--dn \"CN=...\"`."],"exampleFix":"// before\nbsim_ctl adduser\n// after\nbsim_ctl adduser alice","handlingStrategy":"validation","validationCode":"if (args.length <= usernameSlot) {\n    throw new IllegalArgumentException(\"Missing <username> argument for \" + command);\n}","typeGuard":"public boolean hasUsernameArg(String[] args, int slot) {\n    return args != null && args.length > slot && StringUtils.isNotBlank(args[slot]);\n}","tryCatchPattern":"try {\n    bsimControl.exec(args);\n} catch (IllegalArgumentException e) {\n    if (\"Missing username\".equals(e.getMessage())) {\n        usage();\n        return;\n    }\n    throw e;\n}","preventionTips":["Document that user-management commands always take a trailing username.","Validate the full expected arg count in a wrapper."],"tags":["cli","arguments","usage","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}