NationalSecurityAgency/ghidra · error · MalformedURLException

BSim URL missing DB name/path

Error message

BSim URL missing DB name/path

What it means

checkBSimServerURL() validates that the URL has a non-empty path that isn't just '/' — the path represents the database name. If path is null, empty, or equals '/' the MalformedURLException is thrown because BSim requires a database identifier in the URL path.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java:58

		checkBSimServerURL(url);
		return url;
	}

	/**
	 * Validate BSim DB URL.
	 * Acceptable protocols are  postgresql://  https://,  (or possibly http://) file:/
	 * @param url BSim DB URL
	 * @throws MalformedURLException if the URL string is not a support BSim DB URL
	 */
	public static void checkBSimServerURL(URL url) throws MalformedURLException {
		String protocol = url.getProtocol();
		if (!protocol.equals("postgresql") && !protocol.equals("https") &&
			!protocol.equals("elastic") && !protocol.equals("file")) {
			throw new MalformedURLException("Protocol not permissable for BSim URL");
		}
		String path = url.getPath();
		if (path == null || path.length() == 0 || path.equals("/")) {
			throw new MalformedURLException("BSim URL missing DB name/path");
		}
		if (!"file".equals(protocol) && path.indexOf('/', 1) >= 0) {
			throw new MalformedURLException("BSim URL must specify exactly 1 path element");
		}
	}

	/**
	 * Construct the root URL to a specific BSim repository given a "related" URL.
	 * The root URL will have an explicit protocol, a hostname + other mods (the authority), and 1 level of path
	 *    this first level path indicates the particular repository being referenced on the host.
	 * The "related" URL -url- can be an explicitly provided URL pointing to the BSim repository,
	 *    possibly with additional path levels, which are simply stripped from the final root URL.
	 * Alternately -url- can reference a ghidra server, as indicated by the "ghidra" protocol.
	 *    In this case the true BSim URL is derived from ghidra URL in some way
	 * @param urlString is the "related" URL
	 * @return the root BSim URL
	 * @throws MalformedURLException if the given URL string cannot be parsed
	 * @throws URISyntaxException if the given URL string cannot be parsed

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Append the database name as the path: e.g., 'postgresql://myhost/bsimdb' instead of 'postgresql://myhost'.
  2. Ensure the URL construction code includes the database/repository name in the path component.
  3. Remove a bare trailing '/' and replace it with the actual database name.

Example fix

// before
String url = "postgresql://myhost"; // missing DB name
//
// after
String url = "postgresql://myhost/bsimdb";
Defensive patterns

Strategy: validation

Validate before calling

String path = url.getPath();
if (path == null || path.isEmpty() || path.equals("/")) {
    // Require a database name in the path
    throw new IllegalArgumentException(
        "BSim URL must include a database name in the path, e.g., postgresql://host/dbname");
}

Try / catch

try {
    BSimClientFactory.checkBSimServerURL(url);
} catch (MalformedURLException e) {
    if (e.getMessage().contains("missing DB name")) {
        // prompt user for database name
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling checkBSimServerURL(url) where url.getPath() is null, has length 0, or equals '/'. E.g., 'postgresql://myhost' or 'postgresql://myhost/' without a database name.

Common situations: User omits the database name from the URL (provides only host); trailing slash without a name; URL was constructed programmatically and the path component was dropped; user expected the database name to come from a query parameter or default.

Related errors


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