Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2962

Relaxed UUID handling (non binary) is parsed and formatted incorrectly

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.1.0
    • Component/s: None
    • Labels:
    • Not Needed

      bson.js BSON.EJSON facilities are the only BSON drivers to my knowledge that require canonical UUID strings rather than simple hex strings.  The modules also do not allow for urn:uuid: prefixes.

      See: https://github.com/mongodb/js-bson/blob/master/src/uuid.ts

      Here we see that the only acceptable UUID format includes the common hexstring groups separated by a minus symbol.  However the standard in use by other drivers is a simple hexstring formatted as such when EJSON is used in relaxed mode with strict_uuid turned off:

      {{ "uuid" : {}}
        "$uuid" : "d3a8ad3dbd214c0d970cfd4722787f80"
      {{ }}}

      As correcting this would potentially be a breaking change to bson.js I would recommend that BSON.EJSON.stringify/parse be equipped with a flag to handle this properly for users interested in interoperability through spec compliance.  Right now it is easier to send JSON payloads to node and frontend applications from languages like python/go by modifying the payloads before sending and before parsing requests.  This unfortunately breaks the BSON EJSON spec as seen here:

      https://github.com/mongodb/specifications/blob/master/source/extended-json.rst#special-rules-for-parsing-uuid-fields

      ... OR ... 

      The Python and Go EJSON code should be modified to parse both textual formats and get a flag to parse/render those strings as canonical.

      There's simply a formatting mismatch between many drivers with respect to $uuid handling.

            Assignee:
            Unassigned Unassigned
            Reporter:
            spencersr@gmail.com Shane Spencer
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: