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

Error unwrap doesn't support multi-wrapped errors

    • Go Drivers

      Detailed steps to reproduce the problem?

      Related closed issue: https://jira.mongodb.org/browse/GODRIVER-1962

      Wrap two or more errors by fmt.Errorf("%w, %w") or errors.Join(err1, errFromMongoDriver).

       This method will not be able to detect the error from the driver correctly and will make transactions not be retried in my case because the unwrap method is used here.

      package main
      import (
          "errors"
          "fmt"
          "go.mongodb.org/mongo-driver/mongo"
          "go.mongodb.org/mongo-driver/x/mongo/driver"
      )
      
      func main() {
          err := errors.New("customized error")
          labeledErr := mongo.CommandError{Labels: []string{driver.NetworkError}}
          multiWrappedErr := errors.Join(err, labeledErr)
          res := mongo.IsNetworkError(multiWrappedErr)
          fmt.Println(res) // Prints "false", expected to be "true"
      }
      

      Definition of done: what must be done to consider the task complete?

      Add Unwrap() []error assertion handle in this method.

      The exact Go version used, with patch level:

      $ go version

      go version go1.22.1 linux/amd64

      The exact version of the Go driver used:

      $ go list -m go.mongodb.org/mongo-driver

      go.mongodb.org/mongo-driver v1.16.1

      Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

      I set up the MongoDB in docker using the cluster mode with a single node.

      The operating system and version (e.g. Windows 7, OSX 10.8, ...)

      Windows WSL Ubuntu 

      Security Vulnerabilities

      If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here

            Assignee:
            matt.dale@mongodb.com Matt Dale
            Reporter:
            dev.poruta@outlook.com po mux
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: