Skip to content

Commit

Permalink
Plugins: allow setters to return nil (evcc-io#11442)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jan 3, 2024
1 parent 9da3048 commit de3f9ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions provider/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func (p *Go) evaluate() (res any, err error) {
return nil, err
}

if v.IsNil() {
return nil, nil
}

return normalizeValue(v.Interface())
}

Expand Down
4 changes: 4 additions & 0 deletions provider/javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func (p *Javascript) evaluate() (any, error) {
return nil, err
}

if vv == nil {
return nil, nil
}

return normalizeValue(vv)
}

Expand Down
4 changes: 4 additions & 0 deletions provider/transformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func transformInputs(in []inputTransformation, set func(string, any) error) erro

func transformOutputs(out []outputTransformation, v any) error {
for _, cc := range out {
if v == nil {
return fmt.Errorf("no value to transform")
}

if err := cc.function(v); err != nil {
return fmt.Errorf("%s: %w", cc.name, err)
}
Expand Down

0 comments on commit de3f9ba

Please sign in to comment.