{"record":{"id":"5bb254e0ee08bcd8","repo":"NationalSecurityAgency/ghidra","slug":"host-required","errorCode":null,"errorMessage":"host required","messagePattern":"host required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java","lineNumber":84,"sourceCode":"\t/**\n\t * Construct a new {@link BSimServerInfo} object\n\t * \n\t * @param dbType BSim DB type\n\t * @param userinfo connection user info, {@code username[:password]}  (ignored for {@link DBType#file}).  \n\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);","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java#L66-L102","documentation":"Thrown by the BSimServerInfo(DBType, ...) constructor when dbType is postgres or elastic but the host argument is empty. Both network-backed database types require a reachable hostname; a missing host makes the server descriptor meaningless. Throws IllegalArgumentException.","triggerScenarios":"Constructing 'new BSimServerInfo(DBType.postgres, null, \"\", 5432, \"mydb\")' or any call passing a null/blank host for a postgres or elastic DBType.","commonSituations":"Programmatic construction with a host variable that resolved to empty (e.g., unset config value); building a BSimServerInfo from incomplete parsed input.","solutions":["Supply a non-empty host string for postgres/elastic DBTypes.","Validate that the host is set before constructing BSimServerInfo.","If the database is local, use 'localhost' rather than an empty string."],"exampleFix":"// before\nnew BSimServerInfo(DBType.postgres, null, hostFromConfig, 5432, \"bsim\"); // hostFromConfig == \"\"\n// after\nString host = StringUtils.defaultIfBlank(hostFromConfig, \"localhost\");\nnew BSimServerInfo(DBType.postgres, null, host, 5432, \"bsim\");","handlingStrategy":"validation","validationCode":"if ((type == BSimServerInfo.DBType.postgres || type == BSimServerInfo.DBType.elastic) && StringUtils.isEmpty(host)) {\n    throw new IllegalArgumentException(\"host is required for \" + type + \" databases\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate host is non-empty for postgres/elastic DBTypes before constructing BSimServerInfo.","Default unset hosts to 'localhost' when a local DB is intended.","Centralize BSimServerInfo construction behind a builder that enforces per-type invariants."],"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"}