Skip to content

Commit

Permalink
fix: nil value in projection (#440)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly authored Jul 30, 2024
1 parent 42f7e4f commit aade3d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/engine/assert/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func project(ctx context.Context, key any, value any, bindings binding.Bindings,
result: projected,
}, nil
} else {
if reflectutils.GetKind(value) == reflect.Map {
if value == nil {
return nil, nil
} else if reflectutils.GetKind(value) == reflect.Map {
mapValue := reflect.ValueOf(value).MapIndex(reflect.ValueOf(expression.statement))
if !mapValue.IsValid() {
return nil, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/assert/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func Test_project(t *testing.T) {
value: nil,
bindings: nil,
want: nil,
wantErr: true,
wantErr: false,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit aade3d4

Please sign in to comment.