Uploaded image for project: 'Libmongocrypt'
  1. Libmongocrypt
  2. MONGOCRYPT-246

Provide descriptive error message instead of "BSON malformed"

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      When running Ruby FLE tests I received this error from libmongocrypt:

      BSON malformed (libmongocrypt error code 1)
      

      It would be helpful if libmongocrypt indicated why it considers bson to be malformed.

      In this case, we gave libmongocrypt an empty string. In Ruby trying to deserialize an empty string produces:

      irb(main):003:0> Hash.from_bson(BSON::ByteBuffer.new(''))
      Traceback (most recent call last):
              7: from /home/me/.rbenv/versions/2.6/bin/irb:23:in `<main>'
              6: from /home/me/.rbenv/versions/2.6/bin/irb:23:in `load'
              5: from /home/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
              4: from (irb):3
              3: from (irb):3:in `rescue in irb_binding'
              2: from /home/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bson-4.7.0/lib/bson/hash.rb:90:in `from_bson'
              1: from /home/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bson-4.7.0/lib/bson/hash.rb:90:in `get_hash'
      RangeError (Attempted to read 4 bytes, but only 0 bytes remain)
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: