NationalSecurityAgency/ghidra · error · IllegalArgumentException

Invalid in URL

Error message

Invalid  in URL

What it means

Thrown by BSimServerInfo.checkURLField when constructing a BSimServerInfo from a URL and a required URL component (the host for postgres/elastic types, or the path/dbName) is null or empty. The message interpolates the field name (e.g. 'host' or 'path') so the literal string is 'Invalid <field> in URL'. BSim uses this to reject malformed server URLs early before any database connection is attempted.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java:267

		Matcher m = BAD_H2_CHARS_PATTERN.matcher(name);
		if (m.matches()) {
			throw new IllegalArgumentException("Bad character in H2 database path. " +
				"Disallowed characters: " + BAD_H2_CHARS);
		}
		String dbName = name.trim();
		dbName = dbName.replace("\\", "/");
		if ((!dbName.startsWith("/") && !isWindowsFilePath(dbName)) || dbName.endsWith("/")) {
			throw new IllegalArgumentException("Invalid absolute file path: " + dbName);
		}
		if (!dbName.endsWith(H2_FILE_EXTENSION)) {
			dbName += H2_FILE_EXTENSION;
		}
		return dbName;
	}

	private static String checkURLField(String val, String name) {
		if (StringUtils.isEmpty(val)) {
			throw new IllegalArgumentException("Invalid " + name + " in URL");
		}
		return val.trim();
	}

	/**
	 * Determine if this server info corresponds to Windows OS file path.
	 * @return true if this server info corresponds to Windows OS file path.
	 */
	public boolean isWindowsFilePath() {
		return dbType == DBType.file && isWindowsFilePath(dbName);
	}

	/**
	 * Check for Windows path after all '/' chars have been converted to '\' chars.
	 * Example:  {@code C:/a/b/c}
	 * @param path absolute file path
	 * @return true if path appears to be windows path with a drive letter
	 */

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Inspect the full URL string you pass to BSimServerInfo: ensure it contains a non-empty host for postgres/elastic URLs and a non-empty path (the dbName) for all types.
  2. For postgres/elastic use the form 'postgresql://host:port/dbname' and for file use 'file:/absolute/path/to/db.h2'.
  3. If building the URL from java.net.URL, verify url.getHost() and url.getPath() are non-empty before constructing BSimServerInfo.
  4. URL-decode and trim the path mentally to confirm it is not whitespace-only.

Example fix

// before
BSimServerInfo info = new BSimServerInfo(new URL("postgresql:///mydb"));
// after
BSimServerInfo info = new BSimServerInfo(new URL("postgresql://localhost:5432/mydb"));
Defensive patterns

Strategy: validation

Validate before calling

// Validate URL fields before constructing BSimServerInfo
URL url = new URL(urlString);
String host = url.getHost();
String path = url.getPath();
if (url.getProtocol().equals("postgresql") || url.getProtocol().equals("https")) {
    if (host == null || host.trim().isEmpty()) {
        throw new IllegalArgumentException("BSim URL is missing a host component");
    }
}
if (path == null || path.trim().isEmpty() || (path.strip().startsWith("/") && path.strip().length() == 1 && path.strip().substring(1).isEmpty())) {
    throw new IllegalArgumentException("BSim URL is missing a path/dbName component");
}

Try / catch

try {
    BSimServerInfo info = new BSimServerInfo(new URL(urlString));
} catch (IllegalArgumentException e) {
    // message indicates which field ('host' or 'path') was empty
    log.error("Invalid BSim URL '{}': {}", urlString, e.getMessage());
    throw e;
}

Prevention

When it happens

Trigger: Constructing new BSimServerInfo(URL) where url.getHost() returns an empty string for a postgresql:// or https:// URL, or where the URL path is blank/empty (missing dbName). Also fires if the path is empty after stripping a leading slash for postgres/elastic types, or empty for a file: URL.

Common situations: Typo in a BSim URL string (e.g. 'postgresql:///dbname' with no host, or 'file://' with no path). Copy-pasting a URL that lost its host or path component. Building a URL programmatically and forgetting to set the host. URL-encoding issues that collapse the path to empty.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/a361d545806c4ac8. Report an issue: GitHub.