{"record":{"id":"437e4f120b1c52bb","repo":"NationalSecurityAgency/ghidra","slug":"unable-to-infer-ghidra-url-from-bsim-file-db-url","errorCode":null,"errorMessage":"Unable to infer ghidra URL from BSim file DB URL","messagePattern":"Unable to infer ghidra URL from BSim file DB URL","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java","lineNumber":261,"sourceCode":"\t * Establish the URL for the ghidra server and/or the bsim server. At least one string must be non-null\n\t * @param ghidraURLString is the URL string for the ghidra server\n\t * @param bsimURLString is the URL string for the bsim server\n\t * @throws MalformedURLException if there is a problem parsing the given URLs\n\t * @throws URISyntaxException if there is a problem parsing the given URLs\n\t * @throws IllegalArgumentException if unsupported URL use occurs\n\t */\n\tprivate void setupURLs(String ghidraURLString, String bsimURLString)\n\t\t\tthrows MalformedURLException, URISyntaxException {\n\n\t\tif (ghidraURLString != null) {\n\t\t\tsetupGhidraURL(ghidraURLString);\n\t\t}\n\n\t\tif (bsimURLString != null) {\n\t\t\tbsimURL = BSimClientFactory.deriveBSimURL(bsimURLString);\n\t\t\tif (ghidraURL == null) {\n\t\t\t\tif (\"file\".equals(bsimURL.getProtocol())) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"Unable to infer ghidra URL from BSim file DB URL\");\n\t\t\t\t}\n\n\t\t\t\t// Derive Ghidra URL from BSim DB host and dbName\n\t\t\t\tString path = bsimURL.getPath();\n\t\t\t\ttry {\n\t\t\t\t\tpath = URLDecoder.decode(path, \"UTF-8\");\n\t\t\t\t}\n\t\t\t\tcatch (UnsupportedEncodingException e) {\n\t\t\t\t\tthrow new MalformedURLException(e.getMessage());\n\t\t\t\t}\n\t\t\t\tString dbName = path.substring(path.lastIndexOf('/') + 1);\n\n\t\t\t\tghidraURL = GhidraURL.makeURL(bsimURL.getHost(), -1, dbName);\n\t\t\t}\n\t\t}\n\t\telse if (ghidraURLString != null) {\n\t\t\tbsimURL = BSimClientFactory.deriveBSimURL(ghidraURLString);","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java#L243-L279","documentation":"Thrown by setupURLs() when no explicit ghidra URL was provided and the BSim URL uses the 'file' protocol. A file-based BSim database (local H2 file) has no associated network host, so the system cannot infer a ghidra server repository URL from it. The code needs either an explicit ghidra URL or a network-based BSim URL to derive one.","triggerScenarios":"Running 'generatesigs' or 'generateupdates' with a file-based BSim URL (e.g., h2:file:/path/to/db) and neither a --config option nor an explicit ghidra URL. The tool tries to derive ghidraURL from the BSim URL's host, but file:// URLs have no host.","commonSituations":"Using a local BSim database for testing but forgetting to also specify a ghidra repository URL or a config file; mixing local and server deployment paradigms.","solutions":["Provide an explicit ghidra repository URL as the first positional argument: bsim generatesigs ghidra://server/Repo --bsim h2:file:/path/to/db.","Use the --config option with a configuration file that specifies both the ghidra source and BSim target.","If the BSim database is on a network server (not a local file), use a network BSim URL instead of a file:// URL so the host can be inferred."],"exampleFix":"// before\nbsim generatesigs h2:file:/data/bsimdb\n// error: Unable to infer ghidra URL from BSim file DB URL\n\n// after\nbsim generatesigs ghidra://ghidraserver/MyRepo --bsim h2:file:/data/bsimdb","handlingStrategy":"validation","validationCode":"if (ghidraURLString == null && bsimURLString != null) {\n    URL bsimUrl = BSimClientFactory.deriveBSimURL(bsimURLString);\n    if (\"file\".equals(bsimUrl.getProtocol()) && configOption == null) {\n        throw new IllegalArgumentException(\n            \"A ghidra repository URL or --config must be provided when using a file-based BSim URL\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide an explicit ghidra repository URL when using file-based BSim databases.","Use --config for complex setups to specify both ghidra and BSim targets in one file.","Remember that file:// BSim URLs have no host, so ghidra URL inference is impossible."],"tags":["bsim","ghidra","url-validation","command-line","configuration","file-db"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}