NationalSecurityAgency/ghidra · error · IllegalArgumentException
host required
Error message
host required
What it means
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.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java:84
/**
* Construct a new {@link BSimServerInfo} object
*
* @param dbType BSim DB type
* @param userinfo connection user info, {@code username[:password]} (ignored for {@link DBType#file}).
* If blank, {@link ClientUtil#getUserName()} is used.
* @param host host name (ignored for {@link DBType#file})
* @param port port number (ignored for {@link DBType#file}, -1 for default)
* @param dbName name of database (simple database name except for {@link DBType#file}
* which should reflect an absolute file path. On Windows OS the path may start with a
* drive letter.
* @throws IllegalArgumentException if invalid arguments are specified
*/
public BSimServerInfo(DBType dbType, String userinfo, String host, int port, String dbName) {
Objects.requireNonNull(dbType, "DBType must be specified");
this.dbType = dbType;
if ((dbType == DBType.postgres || dbType == DBType.elastic) && StringUtils.isEmpty(host)) {
throw new IllegalArgumentException("host required");
}
dbName = dbName.trim();
if (StringUtils.isEmpty(dbName)) {
throw new IllegalArgumentException("Non-empty dbName required");
}
if (dbType == DBType.file) {
host = null;
port = -1;
userinfo = null;
dbName = cleanupFilename(dbName);
}
else {
if (dbName.contains("/") || dbName.contains("\\")) { // may want additional validation
throw new IllegalArgumentException("Invalid " + dbType + " dbName: " + dbName);
}
userinfo = cleanupUserInfo(userinfo);View on GitHub (pinned to d5f144c24d)
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.
Example fix
// before new BSimServerInfo(DBType.postgres, null, hostFromConfig, 5432, "bsim"); // hostFromConfig == "" // after String host = StringUtils.defaultIfBlank(hostFromConfig, "localhost"); new BSimServerInfo(DBType.postgres, null, host, 5432, "bsim");
Defensive patterns
Strategy: validation
Validate before calling
if ((type == BSimServerInfo.DBType.postgres || type == BSimServerInfo.DBType.elastic) && StringUtils.isEmpty(host)) {
throw new IllegalArgumentException("host is required for " + type + " databases");
} Prevention
- 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.
When it happens
Trigger: Constructing 'new BSimServerInfo(DBType.postgres, null, "", 5432, "mydb")' or any call passing a null/blank host for a postgres or elastic DBType.
Common situations: Programmatic construction with a host variable that resolved to empty (e.g., unset config value); building a BSimServerInfo from incomplete parsed input.
Related errors
- Non-empty dbName required
- Invalid {} dbName: {}
- Remote file URL not supported: {}
- Unsupported BSim URL protocol: {}
- Missing dbName in URL: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/5bb254e0ee08bcd8.
Report an issue: GitHub.