{"record":{"id":"0ca33a1175befc53","repo":"apache/seatunnel","slug":"failed-to-open-amazondocumentdb-source-reader-for","errorCode":null,"errorMessage":"Failed to open AmazonDocumentDB source reader for database [%s], collection [%s]","messagePattern":"Failed to open AmazonDocumentDB source reader for database \\[(.+?)\\], collection \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/source/AmazonDocumentDBSourceReader.java","lineNumber":83,"sourceCode":"\n    public AmazonDocumentDBSourceReader(\n            Context context, AmazonDocumentDBConfig config, SeaTunnelRowType rowType) {\n        this.context = context;\n        this.config = config;\n        this.deserializer = new DocumentDBItemDeserializer(rowType);\n    }\n\n    /** Opens the client once per reader so its connector-local TLS context has reader scope. */\n    @Override\n    public void open() {\n        try {\n            client = createMongoClient();\n            collection =\n                    client.getDatabase(config.getDatabase())\n                            .getCollection(config.getCollection(), BsonDocument.class);\n        } catch (Exception e) {\n            close();\n            throw new IllegalStateException(\n                    String.format(\n                            \"Failed to open AmazonDocumentDB source reader for database [%s], collection [%s]\",\n                            config.getDatabase(), config.getCollection()),\n                    e);\n        }\n    }\n\n    /** Closes the cursor before the client to release the server-side query promptly. */\n    @Override\n    public void close() {\n        closeCursor();\n        if (client != null) {\n            client.close();\n            client = null;\n        }\n    }\n\n    /**","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/source/AmazonDocumentDBSourceReader.java#L65-L101","documentation":"AmazonDocumentDBSourceReader.open establishes the MongoDB client and resolves the configured database/collection when the reader starts. If any exception occurs while creating the client or getting the collection, the reader closes its resources and rethrows as IllegalStateException with the database and collection names, failing task initialization.","triggerScenarios":"createMongoClient() fails (bad host/port, DNS, TLS, invalid credentials, driver classpath problem) or getDatabase(...).getCollection(...) throws; any Exception during open() triggers this wrapped error.","commonSituations":"Wrong connection string or DocumentDB endpoint in config; unreachable DocumentDB (security group/VPC, cluster not in 'available' state); missing TLS truststore for DocumentDB's required TLS; wrong username/password; typo in database or collection name.","solutions":["Verify connectivity to the DocumentDB endpoint (network, VPC/security groups, port 27017) and that the cluster is available.","Check the connection string/credentials in the source config, including TLS settings required by DocumentDB.","Confirm the database and collection names exist (db.getCollectionNames() in mongo shell).","Inspect the cause chain (e) for the root driver exception (e.g. MongoTimeoutException, MongoSecurityException)."],"exampleFix":"// before\nurl = \"mongodb://wrong-host:27017\"\n// after: correct DocumentDB endpoint with TLS\nurl = \"mongodb://user:pass@my-docdb.cluster-xxx.us-east-1.docdb.amazonaws.com:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0\"","handlingStrategy":"try-catch","validationCode":"try (MongoClient probe = MongoClients.create(connectionString)) {\n    probe.getDatabase(dbName).runCommand(new BsonDocument(\"ping\", new BsonInt32(1)));\n} // run before submitting the job","typeGuard":"null","tryCatchPattern":"try { reader.open(); } catch (IllegalStateException e) { log.error(\"DocDB open failed: {}\", e.getCause(), e); throw e; } // inspect e.getCause() for MongoTimeoutException/MongoSecurityException","preventionTips":["Verify endpoint, credentials, and TLS CA bundle before launching the job.","Confirm the DocumentDB cluster is in the same VPC/security-group-reachable from workers.","Validate database/collection names with the mongo shell first."],"tags":["java","documentdb","connection","startup"],"backgroundTag":"connection-refused","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"}