diff --git a/go.mod b/go.mod index f48b781e..9a142942 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ toolchain go1.26.4 require ( github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 - github.com/hashicorp/go-multierror v1.1.1 github.com/mattn/go-isatty v0.0.22 github.com/muesli/mango-cobra v1.3.0 github.com/muesli/roff v0.1.0 @@ -49,6 +48,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect diff --git a/internal/authorizationmodel/model.go b/internal/authorizationmodel/model.go index 274bc410..7f2ea3a6 100644 --- a/internal/authorizationmodel/model.go +++ b/internal/authorizationmodel/model.go @@ -18,12 +18,12 @@ package authorizationmodel import ( "encoding/json" + "errors" "fmt" "os" "path" "time" - "github.com/hashicorp/go-multierror" "github.com/oklog/ulid/v2" pb "github.com/openfga/api/proto/openfga/v1" openfga "github.com/openfga/go-sdk" @@ -207,7 +207,9 @@ func (model *AuthzModel) ReadModelFromModFGA(modFile string) error { } moduleFiles := []language.ModuleFile{} - fileReadErrors := multierror.Error{} + + var fileReadErrors []error + directory := path.Dir(modFile) for _, fileName := range parsedModFile.Contents.Value { @@ -215,8 +217,8 @@ func (model *AuthzModel) ReadModelFromModFGA(modFile string) error { fileContents, err := os.ReadFile(filePath) if err != nil { - fileReadErrors = *multierror.Append( - &fileReadErrors, + fileReadErrors = append( + fileReadErrors, fmt.Errorf("failed to read module file %s due to %w", fileName.Value, err), ) @@ -229,8 +231,8 @@ func (model *AuthzModel) ReadModelFromModFGA(modFile string) error { }) } - if len(fileReadErrors.Errors) != 0 { - return &fileReadErrors + if len(fileReadErrors) != 0 { + return errors.Join(fileReadErrors...) } parsedAuthModel, err := language.TransformModuleFilesToModel(moduleFiles, parsedModFile.Schema.Value)