Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1627

Return structured or configurable error for bson.Unmarshal

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.0
    • Affects Version/s: None
    • Component/s: Error Handling
    • None

      It would be useful for Atlas Data Lake if the errors returned by calls to bson.UnmarshalWithRegistry were structured or configurable so that we could extract certain information that we want to expose to the user (like the tag of the field that errored), and hide our internal implementation details from the user (like the name of the struct that could not be decoded).

      For example, as illustrated in MHOUSE-1425: when we decode a user-supplied command, if the command is not structured properly, we'll get an error from bson.UnmarshalWithRegistry like this:

      cannot decode document into []internalADLStruct
      

      The trouble is that we don't want to expose our internal struct types, and as a result we have to throw out this whole error message, leaving the user with something generic like "failed to parse command".

      So either we'd like to be able to specify that the error message should not include the struct field name. Or even better, it would be great if we got back a structured error that allowed us to manually pull out the tag, struct field name, and given type so that we can craft our own error message.

      I don't quite understand the decoding logic well enough to know how big / possible of an ask this is so let me know. It's not mission critical for ADL, but would definitely result in a better experience for our users.

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            daniel.ernst@mongodb.com Daniel Ernst
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: