{"record":{"id":"b3c4a41f10786655","repo":"apache/seatunnel","slug":"failed-to-open-mongodb-catalog-e-getmessage","errorCode":null,"errorMessage":"Failed to open MongoDB Catalog: ${e.getMessage()}","messagePattern":"Failed to open MongoDB Catalog: (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java","lineNumber":60,"sourceCode":"    private final String catalogName;\n    private final String baseUrl;\n    private transient MongoClient mongoClient;\n    private final String defaultDatabase;\n\n    public MongodbCatalog(String catalogName, String baseUrl, String defaultDatabase) {\n        this.catalogName = catalogName;\n        this.baseUrl = baseUrl;\n        this.defaultDatabase = defaultDatabase;\n    }\n\n    @Override\n    public void open() throws CatalogException {\n        try {\n            if (mongoClient == null) {\n                mongoClient = MongoClients.create(baseUrl);\n            }\n        } catch (Exception e) {\n            throw new CatalogException(\"Failed to open MongoDB Catalog: \" + e.getMessage(), e);\n        }\n    }\n\n    @Override\n    public String name() {\n        return catalogName;\n    }\n\n    @Override\n    public String getDefaultDatabase() throws CatalogException {\n        return defaultDatabase;\n    }\n\n    @Override\n    public boolean databaseExists(String databaseName) throws CatalogException {\n        try {\n            return listDatabases().contains(databaseName);\n        } catch (Exception e) {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java#L42-L78","documentation":"MongodbCatalog.open creates the MongoDB client with MongoClients.create(baseUrl) and wraps any exception into a CatalogException 'Failed to open MongoDB Catalog: <message>'. This is the catalog's initialization step; failure usually means the connection string is malformed or the driver fails at client creation.","triggerScenarios":"Calling catalog.open() when baseUrl is invalid/unparseable, or the driver throws during MongoClients.create (bad URI options, invalid SRV hostname, missing scheme).","commonSituations":"Typo in mongodb:// or mongodb+srv:// URI; unsupported URI options; DNS/seed discovery failures surfacing at client setup; empty or null baseUrl passed via catalog config.","solutions":["Validate the MongoDB connection string format: mongodb://[user:pass@]host[:port][/db][?options] or mongodb+srv://.","Check network/DNS resolution to the MongoDB hosts and that the SRV record exists for +srv URIs.","Verify URI options (replicaSet, ssl, authSource) are supported by the driver version.","Confirm username/password are URL-encoded if they contain special characters."],"exampleFix":"// before\nurl = \"mongodb+srv:/host:27017\"; // malformed scheme\n// after\nurl = \"mongodb+srv://host.example.com:27017/?replicaSet=rs0\";","handlingStrategy":"try-catch","validationCode":"// validate the MongoDB URI before open()\nif (baseUrl == null || !(baseUrl.startsWith(\"mongodb://\") || baseUrl.startsWith(\"mongodb+srv://\"))) {\n    throw new IllegalArgumentException(\"Invalid MongoDB connection string: \" + baseUrl);\n}","typeGuard":null,"tryCatchPattern":"try { catalog.open(); } catch (CatalogException e) { log.error(\"Mongo catalog open failed: {}\", e.getMessage(), e.getCause()); throw e; }","preventionTips":["Test the connection string with mongosh before configuring the catalog","URL-encode credentials containing special characters","Verify DNS/SRV records for mongodb+srv URIs"],"tags":["mongodb","catalog","connection","initialization"],"backgroundTag":"invalid-url-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}