Skip to content

Commit

Permalink
chore: return a false, not an err when unmarshling fails
Browse files Browse the repository at this point in the history
  • Loading branch information
bschaatsbergen committed Mar 16, 2024
1 parent f6fea7b commit 631de14
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/provider/valid_json_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (r ValidJSONFunction) Definition(_ context.Context, _ function.DefinitionRe
Summary: "Checks whether a string is valid JSON",
Parameters: []function.Parameter{
function.StringParameter{
AllowNullValue: false,
AllowNullValue: true,
AllowUnknownValues: true,
Description: "The JSON string to check",
Name: "json",
Expand All @@ -50,7 +50,7 @@ func (r ValidJSONFunction) Run(ctx context.Context, req function.RunRequest, res
isValidJSON, err := isValidJSON(JSON)
if err != nil {
resp.Error = function.ConcatFuncErrors(resp.Error, function.NewFuncError(err.Error()))
return
resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, false))
}

resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, isValidJSON))
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/valid_yaml_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (r ValidYAMLFunction) Run(ctx context.Context, req function.RunRequest, res
isValidYAML, err := isValidYAML(YAML)
if err != nil {
resp.Error = function.ConcatFuncErrors(resp.Error, function.NewFuncError(err.Error()))
return
resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, false))
}

resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, isValidYAML))
Expand Down

0 comments on commit 631de14

Please sign in to comment.