-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
Bug report
For bug reports, provide this information, please:
What Debezium connector do you use and what version?
Debezium Server 3.2.0.Final with MongoDB connector
What is the connector configuration?
# SINK CONFIGURATION debezium.sink.type=kafka debezium.sink.kafka.producer.bootstrap.servers=redpanda:9092 debezium.sink.kafka.producer.key.serializer=org.apache.kafka.common.serialization.StringSerializer debezium.sink.kafka.producer.value.serializer=org.apache.kafka.common.serialization.StringSerializer# Source configuration debezium.source.connector.class=io.debezium.connector.mongodb.MongoDbConnector debezium.source.tasks.max=1 debezium.source.mongodb.connection.string=mongodb://mongo:27017/?replicaSet=rs0 debezium.source.snapshot.mode=no_data debezium.source.filters.match.mode=literal debezium.source.database.include.list=backend debezium.source.topic.prefix=dbserver1# Format configuration debezium.format.value=json debezium.format.value.schemas.enable=false# Transformations debezium.transforms=unwrap debezium.transforms.unwrap.type=io.debezium.connector.mongodb.transforms.ExtractNewDocumentState debezium.transforms.unwrap.array.encoding=document debezium.transforms.unwrap.delete.tombstone.handling.mode=rewrite debezium.transforms.unwrap.delete.tombstone.handling.mode.rewrite-with-id=true debezium.transforms.unwrap.add.fields=op,source.ts_ms:ts_ms,collection,name,version# Storage configuration debezium.source.offset.storage.file.filename=/offset/offsets.dat debezium.source.offset.flush.interval.ms=0
What is the captured database version and mode of deployment?
(E.g. on-premises, with a specific cloud provider, etc.)
mongodb 6.0.7 - self hosted on our k8s cluster
But I also managed to replicate the issue with mongo:8.0.11 running in Docker container with replica set configuration. Deployed using Docker Compose with RedPanda as Kafka broker.
What behavior do you expect?
Debezium Server should successfully process MongoDB change events containing heterogeneous arrays when using array.encoding=document configuration, transforming the data and sending it to Kafka without errors.
What behavior do you see?
Debezium Server fails with a ClassCastException when processing documents containing heterogeneous arrays:
java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.bson.BsonValue at io.debezium.connector.mongodb.transforms.MongoDataConverter.parseMapLists(MongoDataConverter.java:400)
The connector stops processing and the engine fails completely.
Do you see the same behaviour using the latest released Debezium version?
(Ideally, also verify with latest Alpha/Beta/CR version)
Yes, the issue persists in Debezium Server 3.2.0.Final. The problem is in the async processing pipeline where JSON parsing creates LinkedHashMap objects instead of the expected BsonValue objects.
Do you have the connector logs, ideally from start till finish?
(You might be asked later to provide DEBUG/TRACE level log)
debezium-server | 2025-08-19 18:40:42,856 ERROR [io.deb.emb.asy.AsyncEmbeddedEngine] (pool-7-thread-1) Engine has failed with : java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.bson.BsonValue (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; org.bson.BsonValue is in unnamed module of loader 'app') debezium-server | Caused by: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.bson.BsonValue (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; org.bson.BsonValue is in unnamed module of loader 'app') debezium-server | at io.debezium.connector.mongodb.transforms.MongoDataConverter.parseMapLists(MongoDataConverter.java:400) debezium-server | at io.debezium.connector.mongodb.transforms.MongoDataConverter.schema(MongoDataConverter.java:348) debezium-server | at io.debezium.connector.mongodb.transforms.MongoDataConverter.buildSchema(MongoDataConverter.java:212) debezium-server | at io.debezium.connector.mongodb.transforms.ExtractNewDocumentState.newRecord(ExtractNewDocumentState.java:281) debezium-server | at io.debezium.connector.mongodb.transforms.ExtractNewDocumentState.doApply(ExtractNewDocumentState.java:234) debezium-server | at io.debezium.transforms.AbstractExtractNewRecordState.apply(AbstractExtractNewRecordState.java:104) debezium-server | at io.debezium.embedded.Transformations.transform(Transformations.java:92) debezium-server | at io.debezium.embedded.async.ProcessingCallables$TransformAndConvertRecord.call(ProcessingCallables.java:80)
How to reproduce the issue using our tutorial deployment?
- Set up Debezium Server with MongoDB connector using the configuration above
- Create a MongoDB document with heterogeneous arrays:
{ "_id": {"$oid": "66bf4a1c2f8e3b4d5a7c9e12"}, "users": [ {"name": "John", "age": 30, "address": {"street": "123 Main St", "city": "NYC"}}, {"name": "Jane", "email": "jane@example.com", "address": {"street": "456 Oak Ave", "zipcode": "12345"}}, {"name": "Bob", "age": 25, "phone": "555-1234"} ] }
- Insert/update this document in MongoDB
Feature request or enhancement
For feature requests or enhancements, provide this information, please:
Which use case/requirement will be addressed by the proposed feature?
<Your answer>
Implementation ideas (optional)
<Your answer>