Description
The following Error might be observed when using MongoDB Atlas Sink connector on Confluent Cloud:
Could not convert one or more records to a BsonDocument.
Please make sure the input record values contain valid JSON when using String input format.
See Data Formats
Applies To
MongoDB Atlas Sink connector
Confluent Cloud
Cause
This error message indicates that the MongoDB Kafka Sink Connector is encountering issues with the format of the input records.
Specifically, the records being sent to MongoDB are not in a valid JSON format, which is required for conversion to BsonDocument.
Resolution
The recommendation is to correct the "input.data.format" setting in the connector configuration to match the format of the input record.
For example:
Based on the below reference documentation:
- "input.data.format": Sets the input Kafka record value format (data coming from the Kafka topic). Valid entries are AVRO, JSON_SR, PROTOBUF, JSON, STRING, or BSON. You must have Confluent Cloud Schema Registry configured if using a schema-based message format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).
Hence, if the "input.data.format" is set to "STRING" then you need to make sure that all the input records in the topic (associated with the connector) should be a string and that it should contain valid json objects to be parsed by the connector correctly