{"record":{"id":"563b1977166eeaed","repo":"NationalSecurityAgency/ghidra","slug":"missing-dbname-in-url","errorCode":null,"errorMessage":"Missing dbName in URL: {}","messagePattern":"Missing dbName in URL: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java","lineNumber":198,"sourceCode":"\t\t\tport = p <= 0 ? DEFAULT_ELASTIC_PORT : p;\n\t\t}\n\t\telse if (protocol.startsWith(\"file\")) {\n\t\t\tt = DBType.file;\n\t\t\thost = null;\n\t\t\tuserinfo = null;\n\t\t\tport = -1;\n\t\t\tif (!\"\".equals(url.getHost())) {\n\t\t\t\tthrow new IllegalArgumentException(\"Remote file URL not supported: \" + url);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException(\"Unsupported BSim URL protocol: \" + protocol);\n\t\t}\n\t\tdbType = t;\n\n\t\tif (dbType == DBType.postgres || dbType == DBType.elastic) {\n\t\t\tif (!path.startsWith(\"/\")) {\n\t\t\t\tthrow new IllegalArgumentException(\"Missing dbName in URL: \" + url);\n\t\t\t}\n\t\t\tpath = path.substring(1).strip();\n\t\t}\n\t\tpath = urlDecode(checkURLField(path, \"path\"));\n\t\tif (dbType == DBType.file) {\n\t\t\tpath = cleanupFilename(path);\n\t\t}\n\t\telse if (path.contains(\"/\")) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid dbName in URL: \" + path);\n\t\t}\n\t\tdbName = path;\n\t}\n\n\tprivate static String getURLUserInfo(URL url) {\n\n\t\tString userinfo = url.getUserInfo();\n\t\tif (userinfo == null) {\n\t\t\treturn null;","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java#L180-L216","documentation":"Thrown by the BSimServerInfo(URL) constructor for postgres/elastic URLs when the URL path does not start with '/'. The path segment (after the host:port) must contain the database name, and a leading slash is the delimiter that signals a path is present. Throws IllegalArgumentException.","triggerScenarios":"Constructing from a URL like 'postgresql://host:5432' (no trailing path) or 'postgresql://host:5432?' where the path is empty.","commonSituations":"Omitting the database name in a BSim URL; building the URL by string concatenation that dropped the '/dbname' segment.","solutions":["Append the database name as a path, e.g. 'postgresql://host:5432/bsimdb'.","Validate the URL path is non-empty and starts with '/' before constructing.","Use BSimServerInfo's helper methods or the multi-arg constructor if the path is uncertain."],"exampleFix":"// before\nnew BSimServerInfo(new URL(\"postgresql://host:5432\"));\n// after (include dbname in path)\nnew BSimServerInfo(new URL(\"postgresql://host:5432/bsimdb\"));","handlingStrategy":"validation","validationCode":"if ((\"postgresql\".equals(proto) || \"https\".equals(proto) || \"elastic\".equals(proto)) && !url.getPath().startsWith(\"/\")) {\n    throw new IllegalArgumentException(\"URL must include a /<dbname> path\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the /dbname path segment in postgres/elastic BSim URLs.","Validate the URL path is non-empty and starts with '/' before constructing.","Build BSim URLs via a templating helper that guarantees the path segment."],"tags":["bsim","validation","database-url"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}