Skip to content

[Bug](mongodb-cdc) fullDocument JSON string parsing error #663

Description

@ziyanTOP

Problem Summary

When using mongodb-sync-database, Debezium may serialize fullDocument as a JSON string (TextNode) instead of an ObjectNode. The current MongoJsonDebeziumDataChange.extractAfterRow() directly passes this TextNode to JsonNodeExtractUtil.extractAfterRow(), which expects an ObjectNode, causing ClassCastException or deserialization errors.

Root Cause

extractAfterRow() does not check if the fullDocument field is a TextNode. When it is a textual JSON string, it should be parsed into an ObjectNode first.

Proposed Changes

Add a check in extractAfterRow(): if dataNode is textual, parse it with ObjectMapper.readTree() before extracting row data.

Checklist

  1. Does it affect the original behavior: No
  2. Has unit tests been added: No
  3. Has document been added or modified: No Need
  4. Does it need to update dependencies: No
  5. Are there any changes that cannot be rolled back: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions