{"record":{"id":"dd53f1f97a32b513","repo":"apache/seatunnel","slug":"amazondocumentdb-does-not-support-retryable-writes","errorCode":null,"errorMessage":"AmazonDocumentDB does not support retryable writes; remove 'retryWrites=true' from option 'uri' or set it to false","messagePattern":"AmazonDocumentDB does not support retryable writes; remove 'retryWrites=true' from option 'uri' or set it to false","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/config/AmazonDocumentDBConfig.java","lineNumber":99,"sourceCode":"        this.projection =\n                config.getOptional(AmazonDocumentDBSourceOptions.PROJECTION)\n                        .map(String::trim)\n                        .filter(value -> !value.isEmpty())\n                        .orElse(null);\n        this.fetchSize = config.get(AmazonDocumentDBSourceOptions.FETCH_SIZE);\n        this.schema =\n                config.getOptional(ConnectorCommonOptions.SCHEMA)\n                        .map(ReadonlyConfig::fromMap)\n                        .map(ReadonlyConfig::toConfig)\n                        .orElse(null);\n\n        ConnectionString connectionString = parseConnectionString(uri);\n        if (connectionString.getCredential() == null) {\n            throw new IllegalArgumentException(\n                    \"AmazonDocumentDB option 'uri' must include authentication credentials\");\n        }\n        if (hasRetryWritesEnabled(uri)) {\n            throw new IllegalArgumentException(\n                    \"AmazonDocumentDB does not support retryable writes; remove 'retryWrites=true' from option 'uri' or set it to false\");\n        }\n        if (tls) {\n            validateTlsCaFile(tlsCaFile);\n        }\n        validateBsonDocument(matchQuery, \"match.query\");\n        if (projection != null) {\n            validateBsonDocument(projection, \"match.projection\");\n        }\n    }\n\n    /**\n     * Builds driver settings with DocumentDB-safe overrides.\n     *\n     * <p>The URI is applied first and {@code retryWrites(false)} second deliberately: the latter\n     * must win over both driver defaults and any URI option. TLS uses a connector-local {@link\n     * SSLContext} built from the configured CA bundle instead of mutating the JVM-global trust\n     * store, which would affect unrelated connectors running in the same process.","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/config/AmazonDocumentDBConfig.java#L81-L117","documentation":"Amazon DocumentDB does not support MongoDB retryable writes. AmazonDocumentDBConfig inspects the 'uri' option via hasRetryWritesEnabled and throws IllegalArgumentException when retryWrites is enabled, because writes would otherwise fail at runtime against DocumentDB. The error tells you to remove retryWrites=true or set it to false in the URI.","triggerScenarios":"Job startup where the 'uri' option contains 'retryWrites=true' (the default in many MongoDB connection strings copied from Atlas or framework templates), triggering the hasRetryWritesEnabled check in the constructor.","commonSituations":"Copying a MongoDB Atlas URI (Atlas appends retryWrites=true by default) and reusing it for DocumentDB; deploy templates that inject retryWrites=true into all Mongo URIs; legacy config carried over from a real MongoDB migration.","solutions":["Remove retryWrites=true from the uri, or explicitly add retryWrites=false","Replace the Atlas-copied connection string with one built from your DocumentDB cluster endpoint","Audit config templates/secret managers that append retryWrites=true to Mongo URIs and exclude it for DocumentDB"],"exampleFix":"// before\nuri = \"mongodb://admin:pass@docdb.cluster.amazonaws.com:27017/?retryWrites=true\"\n// after\nuri = \"mongodb://admin:pass@docdb.cluster.amazonaws.com:27017/?retryWrites=false\"","handlingStrategy":"validation","validationCode":"// reject retryWrites before job submission\nfunction assertNoRetryWrites(uri) {\n  const q = uri.split('?')[1] || '';\n  for (const kv of q.split('&')) {\n    const [k, v] = kv.split('=');\n    if (k === 'retryWrites' && v !== 'false') {\n      throw new Error(\"DocumentDB: remove retryWrites=true from uri or set retryWrites=false\");\n    }\n  }\n}\nassertNoRetryWrites(config.uri);","typeGuard":"boolean retryWritesDisabled(String uri) {\n  int q = uri.indexOf('?');\n  if (q < 0) return true;\n  for (String p : uri.substring(q + 1).split(\"&\")) {\n    if (p.startsWith(\"retryWrites=\")) return p.substring(\"retryWrites=\".length()).equalsIgnoreCase(\"false\");\n  }\n  return true;\n}","tryCatchPattern":"try {\n    AmazonDocumentDBConfig config = new AmazonDocumentDBConfig(readonlyConfig);\n} catch (IllegalArgumentException e) {\n    if (String.valueOf(e.getMessage()).contains(\"retryable writes\")) {\n        throw new IllegalArgumentException(\"Replace the uri with one that has retryWrites=false (Atlas default URIs are not valid for DocumentDB)\", e);\n    }\n    throw e;\n}","preventionTips":["Never reuse Atlas/Compass-generated URIs verbatim — they append retryWrites=true by default","Add retryWrites=false explicitly to every DocumentDB uri so intent is visible","Lint connector configs in CI for the retryWrites parameter on DocumentDB URIs","When migrating from MongoDB to DocumentDB, diff the connection options, not just host/credentials"],"tags":["amazondocumentdb","mongodb-uri","retryable-writes","incompatibility"],"backgroundTag":"invalid-config-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}