{"record":{"id":"9ee361fc13d2ba62","repo":"NationalSecurityAgency/ghidra","slug":"invalid-dbname-in-url","errorCode":null,"errorMessage":"Invalid dbName in URL: {}","messagePattern":"Invalid 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":207,"sourceCode":"\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;\n\t\t}\n\n\t\tint pwSep = userinfo.indexOf(':');\n\t\tString urlUserInfo;\n\t\tif (pwSep >= 0) {\n\t\t\turlUserInfo = urlDecode(userinfo.substring(0, pwSep)) + \":\" +\n\t\t\t\turlDecode(userinfo.substring(pwSep + 1));\n\t\t}\n\t\telse {","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java#L189-L225","documentation":"Thrown by the BSimServerInfo(URL) constructor for postgres/elastic URLs when, after stripping the leading slash, the database name still contains a '/'. Network database names must be a single path segment; a multi-segment path indicates an invalid or misplaced database name. Throws IllegalArgumentException.","triggerScenarios":"Constructing from a URL like 'postgresql://host:5432/foo/bar' where the path after the host contains more than one segment.","commonSituations":"Embedding a directory hierarchy in the database name; treating a postgres URL like a file path; URL-encoding mistakes that leave extra slashes.","solutions":["Use a single-segment database name in the URL path, e.g. 'postgresql://host:5432/bsimdb'.","If you intended a file path, use the file:// protocol instead.","Sanitize the path so it contains no slashes after the leading one."],"exampleFix":"// before\nnew BSimServerInfo(new URL(\"postgresql://host:5432/apps/bsimdb\"));\n// after (single-segment name)\nnew BSimServerInfo(new URL(\"postgresql://host:5432/bsimdb\"));","handlingStrategy":"validation","validationCode":"String path = url.getPath().substring(1);\nif (path.contains(\"/\")) {\n    throw new IllegalArgumentException(\"postgres/elastic dbName must be a single path segment: \" + path);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a single-segment database name in postgres/elastic URL paths.","Route multi-segment paths to the file:// protocol if a file is intended.","Sanitize paths to remove stray slashes before constructing."],"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"}