{"record":{"id":"e962cfb64e4480c1","repo":"NationalSecurityAgency/ghidra","slug":"resultfolder-getabsolutepath-is-not-a-valid-di","errorCode":null,"errorMessage":"{resultFolder.getAbsolutePath()} is not a valid directory","messagePattern":"(.+?) is not a valid directory","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BulkSignatures.java","lineNumber":985,"sourceCode":"\t\tquery.spec.exemd5 = md5;\n\t\tquery.spec.exename = name;\n\t\tquery.spec.arch = null;\n\t\tquery.spec.execompname = null;\n\n\t\tdoDumpSigs(resultFolder, query);\n\t}\n\n\t/**\n\t * Exports information about a binary to a local folder in XML format.\n\t * \n\t * @param resultFolder the folder where the results will be stored\n\t * @param query the query object containing the params of the query\n\t * @throws IOException if there's an error establishing the database connection\n\t * @throws LSHException if there's an error issuing the query\n\t */\n\tprotected void doDumpSigs(File resultFolder, QueryName query) throws IOException, LSHException {\n\t\tif (!resultFolder.isDirectory()) {\n\t\t\tthrow new IOException(resultFolder.getAbsolutePath() + \" is not a valid directory\");\n\t\t}\n\n\t\tDatabaseInformation info = establishQueryServerConnection(true);\n\t\tquery.fillinCallgraph = info.trackcallgraph;\n\t\tResponseName responseName = query.execute(querydb);\n\t\tif (responseName == null) {\n\t\t\tBSimError lastError = querydb.getLastError();\n\t\t\tthrow new LSHException(lastError.message);\n\t\t}\n\t\tif (!responseName.uniqueexecutable) {\n\t\t\tthrow new LSHException(\"Could not determine unique executable\");\n\t\t}\n\t\tExecutableRecord exe;\n\t\tif (!StringUtils.isAllBlank(query.spec.exemd5)) {\n\t\t\texe = responseName.manage.findExecutable(query.spec.exemd5);\n\t\t}\n\t\telse {\n\t\t\texe = responseName.manage.findExecutable(query.spec.exename, query.spec.arch,","sourceCodeStart":967,"sourceCodeEnd":1003,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BulkSignatures.java#L967-L1003","documentation":"Thrown by doDumpSigs when resultFolder.isDirectory() returns false. This means the path either does not exist or exists but is a regular file rather than a directory. Signature files will be written into this folder, so it must be a valid writable directory.","triggerScenarios":"Calling doDumpSigs with a resultFolder path that doesn't exist, points to a file, or is a broken symlink. The check is purely isDirectory() — no writability test.","commonSituations":"User specifies an output folder that hasn't been created yet; the path points to an existing file; the directory is on a read-only mount; typo in the folder path.","solutions":["Create the directory before calling doDumpSigs: resultFolder.mkdirs().","Verify the path is not already occupied by a regular file.","Check write permissions on the directory and its parent.","Use an absolute path to avoid working-directory ambiguity."],"exampleFix":"// before\nif (!resultFolder.isDirectory()) {\n    throw new IOException(resultFolder.getAbsolutePath() + \" is not a valid directory\");\n}\n\n// after — attempt creation, then validate\nif (!resultFolder.exists()) {\n    if (!resultFolder.mkdirs()) {\n        throw new IOException(\"Cannot create output directory: \" + resultFolder.getAbsolutePath());\n    }\n} else if (!resultFolder.isDirectory()) {\n    throw new IOException(resultFolder.getAbsolutePath() + \" is not a directory\");\n}","handlingStrategy":"validation","validationCode":"// Ensure the output directory exists and is writable before calling doDumpSigs\nif (resultFolder == null) {\n    throw new IllegalArgumentException(\"resultFolder must not be null\");\n}\nif (!resultFolder.exists()) {\n    resultFolder.mkdirs();\n}\nif (!resultFolder.isDirectory()) {\n    throw new IllegalArgumentException(\n        \"resultFolder is not a directory: \" + resultFolder.getAbsolutePath());\n}\nif (!resultFolder.canWrite()) {\n    throw new IllegalArgumentException(\n        \"resultFolder is not writable: \" + resultFolder.getAbsolutePath());\n}","typeGuard":"public static boolean isValidOutputDirectory(File dir) {\n    return dir != null && dir.isDirectory() && dir.canWrite();\n}","tryCatchPattern":"// Validation-based; create directory proactively\nif (!resultFolder.exists()) {\n    resultFolder.mkdirs();\n}\nbulk.doDumpSigs(resultFolder, query);","preventionTips":["Create the output directory with mkdirs() before calling doDumpSigs.","Check canWrite() to catch read-only filesystem issues early.","Use absolute paths for output directories to avoid ambiguity."],"tags":["bsim","file-io","validation","dump-sigs"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}