Skip to content

[flink] Read absent parser paths as NULL in MongoDB specified mode - #11440

Open
LuciferYang wants to merge 2 commits into
apache:masterfrom
LuciferYang:fix/mongo-specified-missing-path
Open

LuciferYang wants to merge 2 commits into
apache:masterfrom
LuciferYang:fix/mongo-specified-missing-path

Conversation

@LuciferYang

@LuciferYang LuciferYang commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

close #11439

In MongoDB CDC schema.start.mode=specified, every update, replace or delete failed the job with PathNotFoundException. These events build their DELETE record from documentKey, which holds only _id, and JsonPath.read throws for a configured path that matches nothing.

MongoVersionStrategy.parseFieldsFromJsonRecord now reads an absent path as NULL, the same as an absent field in dynamic mode. A field present with a JSON null still becomes "{}", and a malformed path still throws InvalidPathException.

A DELETE built from documentKey still has no value for a partition key on another document field, in either mode. The MongoDB CDC page and the --partition_keys option of both actions now say that such a table keeps the old row of a deleted or moved document. One behavior change: a misspelled path for a non-key field now gives a NULL column instead of failing on the first record.

Tests

  • Mongo4VersionStrategyTest: a delete, an update, and an insert missing a configured field each produce records with the absent column NULL. All three threw PathNotFoundException before the fix.
  • MongoDBSyncTableActionITCase#testSpecifiedModeCDCOperations: a specified-mode job applies update, replace and delete events and ends with the expected rows. Before the fix the job failed on the first update and the test reported the PathNotFoundException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MongoDB CDC specified mode fails on every update, replace or delete

1 participant