Skip to content

Commit

Permalink
Fix crash if a non-module is passed to TransformModuleFilesToModel
Browse files Browse the repository at this point in the history
  • Loading branch information
pow-devops2020 committed Nov 20, 2024
1 parent ff7db03 commit 9633431
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/go/transformer/module-to-model.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,15 @@ func TransformModuleFilesToModel( //nolint:funlen,gocognit,cyclop
}

types = append(types, typeDef.GetType())
typeDef.Metadata.SourceInfo = &openfgav1.SourceInfo{
File: module.Name,
if typeDef.Metadata != nil {
typeDef.Metadata.SourceInfo = &openfgav1.SourceInfo{
File: module.Name,
}
} else {
transformErrors = multierror.Append(transformErrors, &ModuleTransformationSingleError{
Msg: "file is not a module",
})
continue
}
rawTypeDefs = append(rawTypeDefs, typeDef)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[
{
"msg": "file is not a module",
"file":"nomodule.fga"
},
{
"msg": "duplicate condition a_check",
"file": "org.fga",
Expand Down

0 comments on commit 9633431

Please sign in to comment.