Repository navigation
fix(mongodb): keep ObjectId type through Find store then Load copy - #204
Malaydewangan09 merged 6 commits into
Conversation
MongoDbService.map() returned a bare hex string for OBJECT_ID while every other type without a JSON equivalent was wrapped in Extended JSON. Load decodes only wrapper maps, so a bare hex string loaded back as a String and the copy stopped matching the source under BSON type-aware equality: $lookup, ObjectId equality filters and {$type: "objectId"} all returned nothing, while both tasks reported SUCCESS.
Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
Hi maintainers, this PR is ready for review. The CI run is parked at the first-time-contributor approval gate (0 check runs so far); could someone please approve the run when convenient? Thanks. |
The Trigger reuses Find, so its rows now carry ObjectIds as $oid wrappers, the same form this PR already gives Find rows. Three TriggerWatermarkTest assertions still pinned the old bare hex string form, which is what CI failed on (3 failed, 134 passed). The watermark internals are untouched: the stored position still holds the raw ObjectId, as the passing storedPosition assertion shows.
|
CI on 43a4b2d failed in 3 TriggerWatermarkTest assertions (134 passed, 3 failed). The Trigger reuses Find, so its rows now carry ObjectIds as $oid wrappers, the same form this PR gives Find rows. The 3 assertions still pinned the old bare hex string form, so I updated them in 83bc015. The watermark internals are untouched: the stored position still holds the raw ObjectId, as the passing storedPosition assertion shows. Waiting on the rerun to confirm green. |
Malaydewangan09
left a comment
There was a problem hiding this comment.
Thanks, the fix works, I ran the full suite against MongoDB and the copy now keeps every ObjectId. The catch is that it changes _id from a hex string to {"$oid": ...} in every Find, Aggregate and Trigger output, which breaks flows reading rows[0]._id. Could you keep hex as the default and add an opt-in property (e.g. objectIdFormat: HEX | EXTENDED_JSON) that uses the $oid form?
… opt-in Hex stays the default, so flows reading rows[0]._id keep working. Find, Aggregate and Trigger take objectIdFormat (HEX or EXTENDED_JSON); EXTENDED_JSON keeps the $oid form, so Find with store: true followed by Load still keeps ObjectIds. Both review nits are in: the map comment is a single short line, and the CrudTest assertion uses getFirst(). Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
Thanks for running the full suite against MongoDB and catching the output change, you are right that breaking rows[0]._id is worse than the default fix. Done in the latest push: hex is the default again, and Find, Aggregate and Trigger now take objectIdFormat with HEX and EXTENDED_JSON. EXTENDED_JSON keeps the $oid form, so a Find with store: true followed by Load still keeps ObjectIds, and the store and fetch paths on both tasks plus the Trigger pass-through all use it. The two nits are in as well. Let me know if the property should live anywhere else, or if you want the default documented anywhere beyond the property description. |
Malaydewangan09
left a comment
There was a problem hiding this comment.
Thanks, the default output now matches main and the copy keeps every ObjectId, the tests pass here. It conflicts with main though: #208 added new map() callers in Find and Aggregate, and main has a new BINARY case next to the moved OBJECT_ID one. Could you merge main? A few small things inline, plus an Aggregate test with EXTENDED_JSON and IdUtils.create() for the ids in the new Trigger test.
Could you also add a screenshot of a Find with store: true then Load keeping the ObjectId?
…objectid-roundtrip # Conflicts: # src/main/java/io/kestra/plugin/mongodb/Aggregate.java # src/main/java/io/kestra/plugin/mongodb/Find.java # src/main/java/io/kestra/plugin/mongodb/MongoDbService.java
Use var rObjectIdFormat in Find and Aggregate and pass it to the fetch and store paths, convert the objectIdFormat descriptions in Find, Aggregate and Trigger to text blocks noting rows[0]._id becomes a map with $oid under EXTENDED_JSON, add an Aggregate test with EXTENDED_JSON, and use IdUtils.create() for the ids in the new Trigger test. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
Done, every point from this review is in (head ba35d4a):
One honest caveat: the MongoDB-backed suite could not run here (no Docker for Testcontainers, and the Gradle daemon fails to start in this sandbox), so this push is not verified by a local test run yet. CI is the check for that. |
|
The tests from main still called I pushed these tweaks. |
Closes #193
A Find with
store: truewrote ObjectIds as bare hex strings, so a Load of that file inserted them back as strings and the copy lost the ObjectId type.Find, Aggregate and Trigger get an
objectIdFormatproperty.HEX(default) keeps the current output, sorows[0]._idis still a hex string and existing flows are unchanged.EXTENDED_JSONwrites ObjectIds as{"$oid": "..."}, which Load turns back into ObjectIds, so Findstore: truethen Load keeps the type, nested and array values included.Tests run against MongoDB:
BsonTypesTest.findStoreThenLoadKeepsObjectIdscovers the round trip, plusEXTENDED_JSONcases for Aggregate and Trigger, and the defaultHEXoutput is asserted unchanged for all three.