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

Return structured or configurable error for bson.Unmarshal

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.0
    • Component/s: Error Handling
    • Security Level: Public
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            divjot.arora Divjot Arora
            Reporter:
            daniel.ernst Daniel Ernst
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: