-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
TAR 2024-07-08, TAR 2024-07-22
-
5
-
Tools and Replicator
Problem Statement/Rationale
If mongodump dumps a view without an error. Mongorestore should not produce a format error when restoring the dumped file.
Steps to Reproduce
Create a view that has the following definition using the go driver:
pipeline := []bson.M{ {"$match": bson.D{ {"createdAt", bson.D{ {"$gte", bson.D{{"$date", "2024-05-20T23:59:59Z"}}}}, }}, }, } createCmd := bson.D{ {"create", "test view"}, {"viewOn", colName}, {"pipeline", pipeline}, }
Note that the document within $gte is an object instead of a date. Both key and value are strings, but the key is "$date".
Run mongodump and mongorestore on this view.
Expected Results
Mongorestore should restore the view with the same pipeline.
Actual Results
Mongoresture fails with an error:
Failed: restore error: error parsing metadata from archive <file>: invalid JSON input; expected {
Additional Notes
Mongodump uses the go driver marshal function to dump a view's definition from BSON to canonical ext JSON format:
bson.MarshalExtJSON(meta, true, false)
Mongorestore does the reverse:
bson.UnmarshalExtJSON(jsonBytes, true, meta)
MarshalExtJSON marshals the format without an error, but UnmarshalExtJSON on the previously marshaled content returns the format error.
- depends on
-
GODRIVER-3273 Marshaling and unmarshaling should not produce a JSON format error on $-prefixed object keys
- Closed
- links to