apache/seatunnel · error · CatalogException
Failed to check database existence: ${databaseName}
Error message
Failed to check database existence: ${databaseName} What it means
MongodbCatalog.databaseExists checks membership in listDatabases() and wraps any exception in a CatalogException 'Failed to check database existence: <databaseName>'. It is called by listTables and createTable, so a connectivity or authorization failure during database listing surfaces here.
Source
Thrown at seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java:79
}
}
@Override
public String name() {
return catalogName;
}
@Override
public String getDefaultDatabase() throws CatalogException {
return defaultDatabase;
}
@Override
public boolean databaseExists(String databaseName) throws CatalogException {
try {
return listDatabases().contains(databaseName);
} catch (Exception e) {
throw new CatalogException("Failed to check database existence: " + databaseName, e);
}
}
@Override
public List<String> listDatabases() throws CatalogException {
try {
List<String> dbs = new ArrayList<>();
for (String name : mongoClient.listDatabaseNames()) {
dbs.add(name);
}
return dbs;
} catch (Exception e) {
throw new CatalogException("Failed to list databases", e);
}
}
@Override
public List<String> listTables(String databaseName)View on GitHub (pinned to cf67b549a7)
Solutions
- Verify the MongoDB instance is reachable (ping/openssl check on host:port) and the URI in the catalog config is correct.
- Grant the catalog user the listDatabases privilege (cluster scope) or use a user with sufficient roles.
- Check authSource and credentials; test the same URI with mongosh.
- Inspect the wrapped cause ('Caused by') for the concrete driver error (timeout, auth, command not authorized).
Example fix
// before
user = { role: 'readWrite', db: 'mydb' } // cannot listDatabases
// after
user = { role: 'readWriteAnyDatabase', db: 'admin' } // or explicitly grant { role: 'clusterMonitor' } Defensive patterns
Strategy: try-catch
Validate before calling
// check reachability and auth before catalog calls
try (MongoClient c = MongoClients.create(baseUrl)) {
c.listDatabaseNames().first(); // throws if unreachable/unauthorized
} Try / catch
try { exists = catalog.databaseExists(db); } catch (CatalogException e) { log.error("databaseExists failed for {}: {}", db, e.getCause(), e); throw e; } Prevention
- Grant the catalog user listDatabases/clusterMonitor privileges
- Verify host, port, authSource and credentials with mongosh
- Always inspect the wrapped cause of CatalogException for the concrete driver error
When it happens
Trigger: Calling databaseExists (directly or via listTables/createTable) when the MongoDB server is unreachable, authentication fails, or the listDatabases command is rejected by the server.
Common situations: Wrong credentials or missing listDatabases privilege for the user; MongoDB down or wrong host/port in the URI; firewall or TLS issues; using a user scoped to a single database without cluster-wide list permission.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Failed to list databases
- Database ${databaseName} already exists in catalog hive
- Failed to querySQLResult
- Failed to open MongoDB Catalog: ${e.getMessage()}
- Failed to list databases
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/e90fc657e7d65851.
Report an issue: GitHub.