Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1887

Warn when silently converting JS undefined to null.

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      OS:
      node.js / npm versions:
      Additional info:

      Problem Statement/Rationale

      Server v8 has subtly changed how it matches BSON undefined values with BSON null. The example given in the compatibility doc, though, doesn’t work on mongosh because mongosh silently maps all JS undefined values to BSON null rather than BSON undefined.

      While the rationale for that mapping is documented, it’s quite surprising and could conceivably corrupt customer data.

      Steps to Reproduce

      Follow the example in the 8.0 compat document: create a people collection with the three documents shown, then run the find() command given.

      Expected Results

      One of the following:

      1. The example would work as expected: I’d see two documents. There’d be a warning about the use of BSON undefined.
      2. mongosh would warn about the use of deprecated BSON undefined but still do the insert.
      3. mongosh would throw on use of BSON undefined.

      Actual Results

      I see 3 documents because the one that I expect to have BSON undefined has BSON null instead.

      Additional Notes

      Any additional information that may be useful to include.

            Assignee:
            Unassigned Unassigned
            Reporter:
            felipe.gasper@mongodb.com Felipe Gasper
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: