{"record":{"id":"7a187967781742d7","repo":"NationalSecurityAgency/ghidra","slug":"missing-data-directory","errorCode":null,"errorMessage":"Missing data directory","messagePattern":"Missing data directory","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":948,"sourceCode":"\t\t// Patch the configuration\n\t\ttuneConfig(configCopy, configFile, hbaCopy, hbaFile, serverConfigFile);\n\t\tSystem.out.println(\"Generating servers SSL certificate\");\n\t\tgenerateSelfSignedCertificate(new File(dataDirectory, \"server.crt\"),\n\t\t\tnew File(dataDirectory, \"server.key\"));\n\t}\n\n\t/**\n\t * Scan the PostgreSQL data directory from the command-line\n\t * Make sure the directory exists and establish the File object -dataDirectory-\n\t * @param params are the command-line arguments\n\t * @param slot is the position to retrieve the data directory argument\n\t * @throws IllegalArgumentException if the data directory is invalid\n\t * @throws IOException if the canonical file cannot be retrieved\n\t */\n\tprivate void scanDataDirectory(String[] params, int slot)\n\t\t\tthrows IllegalArgumentException, IOException {\n\t\tif (params.length <= slot) {\n\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\");","sourceCodeStart":930,"sourceCodeEnd":966,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L930-L966","documentation":"Thrown by scanDataDirectory(params, slot) when the command-line arguments are shorter than expected — the positional data-directory argument is absent. BSim needs the data directory path for virtually every subcommand (start/stop/status/adduser/dropuser/changeauth).","triggerScenarios":"Invoking a bsim_ctl subcommand that expects a data directory argument but providing too few args, e.g. `bsim_ctl start` with the directory argument omitted.","commonSituations":"Missing trailing positional argument; quoting accident that swallowed the path; copy-paste from docs that used a placeholder never replaced; argument reordering.","solutions":["Append the data directory path as the positional argument: `bsim_ctl <command> [options] <dataDir>`.","Check the command usage/help for the expected argument order.","Quote paths containing spaces."],"exampleFix":"// before\nbsim_ctl start\n// after\nbsim_ctl start /var/bsim/data","handlingStrategy":"validation","validationCode":"// Validate the argument vector shape before delegating to BSimControlLaunchable.\nif (args.length < expectedSlot + 1) {\n    throw new IllegalArgumentException(\n        \"Missing required <dataDir> positional argument\");\n}","typeGuard":"public boolean hasDataDirArg(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 data directory\".equals(e.getMessage())) {\n        usage();  // print help and exit nonzero\n        return;\n    }\n    throw e;\n}","preventionTips":["Wrap bsim_ctl in a script that checks arg count and prints usage.","Pin argument order in documented wrapper commands.","Quote paths to avoid shell tokenization surprises."],"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"}