{"record":{"id":"e1e6a7de850d40b9","repo":"NationalSecurityAgency/ghidra","slug":"non-empty-dbname-required","errorCode":null,"errorMessage":"Non-empty dbName required","messagePattern":"Non-empty dbName required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java","lineNumber":89,"sourceCode":"\t *   If blank, {@link ClientUtil#getUserName()} is used.\n\t * @param host host name (ignored for {@link DBType#file})\n\t * @param port port number (ignored for {@link DBType#file}, -1 for default)\n\t * @param dbName name of database (simple database name except for {@link DBType#file}\n\t * which should reflect an absolute file path.  On Windows OS the path may start with a\n\t * drive letter.\n\t * @throws IllegalArgumentException if invalid arguments are specified\n\t */\n\tpublic BSimServerInfo(DBType dbType, String userinfo, String host, int port, String dbName) {\n\t\tObjects.requireNonNull(dbType, \"DBType must be specified\");\n\t\tthis.dbType = dbType;\n\n\t\tif ((dbType == DBType.postgres || dbType == DBType.elastic) && StringUtils.isEmpty(host)) {\n\t\t\tthrow new IllegalArgumentException(\"host required\");\n\t\t}\n\n\t\tdbName = dbName.trim();\n\t\tif (StringUtils.isEmpty(dbName)) {\n\t\t\tthrow new IllegalArgumentException(\"Non-empty dbName required\");\n\t\t}\n\n\t\tif (dbType == DBType.file) {\n\t\t\thost = null;\n\t\t\tport = -1;\n\t\t\tuserinfo = null;\n\t\t\tdbName = cleanupFilename(dbName);\n\t\t}\n\t\telse {\n\t\t\tif (dbName.contains(\"/\") || dbName.contains(\"\\\\\")) { // may want additional validation\n\t\t\t\tthrow new IllegalArgumentException(\"Invalid \" + dbType + \" dbName: \" + dbName);\n\t\t\t}\n\t\t\tuserinfo = cleanupUserInfo(userinfo);\n\t\t\tif (port <= 0) {\n\t\t\t\tport = -1;\n\t\t\t}\n\t\t\tif (dbType == DBType.postgres && port <= 0) {\n\t\t\t\tport = DEFAULT_POSTGRES_PORT;","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java#L71-L107","documentation":"Thrown by the BSimServerInfo(DBType, ...) multi-argument constructor when, after trimming, the dbName argument is empty. Every database type requires a non-empty database name. Throws IllegalArgumentException.","triggerScenarios":"Calling the multi-arg constructor with a null, blank, or whitespace-only dbName argument (e.g. 'new BSimServerInfo(DBType.postgres, null, \"host\", 5432, \"  \")').","commonSituations":"dbName sourced from an unset or whitespace-only configuration field; parsing a URL/connection string that omitted the database name.","solutions":["Ensure the dbName argument is a non-empty, trimmed value before constructing.","Validate dbName with StringUtils.isBlank() and fail early with a clearer message.","Check the upstream configuration that populates the dbName."],"exampleFix":"// before\nnew BSimServerInfo(DBType.postgres, null, \"host\", 5432, dbNameField); // dbNameField is \"  \"\n// after\nif (StringUtils.isBlank(dbNameField)) throw new IllegalArgumentException(\"dbName not configured\");\nnew BSimServerInfo(DBType.postgres, null, \"host\", 5432, dbNameField);","handlingStrategy":"validation","validationCode":"if (StringUtils.isBlank(dbName)) {\n    throw new IllegalArgumentException(\"dbName must be non-empty\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check dbName with StringUtils.isBlank() before constructing.","Fail early in configuration loading when the database name is unset.","Wrap BSimServerInfo construction in a factory that validates all fields."],"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"}