NationalSecurityAgency/ghidra · error · LSHException

Missing databaseName for drop database

Error message

Missing databaseName for drop database

What it means

`fdbDatabaseDrop` requires `query.databaseName` to be non-null. If it is null, LSHException is thrown before any drop is attempted. This is required-field validation for the DropDatabase command; immediately after, the name must also match the connected DB's name or UnsupportedOperationException fires.

Solutions

  1. Set query.databaseName to the target database name before dispatching.
  2. Validate the DropDatabase command object (non-null name, and name matches the connection) before sending.
  3. Use a builder that enforces required fields.

Example fix

// before
DropDatabase cmd = new DropDatabase();
cmd.databaseName = null;                  // throws
// after
DropDatabase cmd = new DropDatabase();
cmd.databaseName = "my_bsim_db";
Defensive patterns

Strategy: validation

Validate before calling

// Require a non-null, matching database name before dropping.
if (query.databaseName == null) {
    throw new IllegalArgumentException("DropDatabase requires databaseName");
}
if (!query.databaseName.equals(ds.getServerInfo().getDBName())) {
    throw new IllegalArgumentException("databaseName must match the connected DB");
}

Type guard

// isDropRequestValid: true iff databaseName is set and matches the connection.
static boolean isDropRequestValid(DropDatabase q, DataSource ds) {
    return q.databaseName != null
        && q.databaseName.equals(ds.getServerInfo().getDBName());
}

Try / catch

try {
    db.fdbDatabaseDrop(query);
} catch (LSHException e) {
    if (e.getMessage().equals("Missing databaseName for drop database")) {
        throw new IllegalArgumentException("Set query.databaseName before drop", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Issuing a DropDatabase request without setting databaseName (left null from construction, deserialization, or a builder that skipped the field).

Common situations: Programmatic command construction omitting required fields; deserialization gaps from a malformed request; copy-paste of a command template without filling the name.

Related errors


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

Appendix: source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java:2103

			FunctionDescription func =
				queryByNameAddress(response.manage, exe, entry.funcName, entry.address, true);
			if (func == null) {
				throw new LSHException("Could not find function: " + entry.funcName);
			}
			response.correspond.add(func);
		}

		TreeMap<RowKey, FunctionDescription> funcmap = new TreeMap<>();
		response.manage.generateFunctionIdMap(funcmap);
		for (FunctionDescription element : response.correspond) {
			fillinChildren(element, response.manage, funcmap);
		}
	}

	private void fdbDatabaseDrop(DropDatabase query) throws LSHException {
		ResponseDropDatabase response = query.getResponse();
		if (query.databaseName == null) {
			throw new LSHException("Missing databaseName for drop database");
		}
		if (!query.databaseName.equals(ds.getServerInfo().getDBName())) {
			throw new UnsupportedOperationException("drop database name must match");
		}
		response.dropSuccessful = true;		// Response parameters assuming success
		response.errorMessage = null;
		try {
			dropDatabase();
		}
		catch (SQLException e) {
			String msg = e.getMessage();
			if (msg.indexOf("database \"" + query.databaseName + "\" does not exist") > 0) {
				return; // missing database
			}
			response.dropSuccessful = false;
			response.errorMessage = e.getMessage();
		}
	}

View on GitHub (pinned to d5f144c24d)