Skip to content

Commit 42e7b4d

Browse files
$split: return undefined for non-string input (RecoLabs#1)
The jsonata npm package returns undefined when $split receives a non-string first argument (number, boolean, etc.), but gnata threw a hard T0410 error. This divergence caused silent evaluation mismatches when gnata was used as a drop-in replacement. Return nil (undefined) instead of erroring, matching the reference jsonata behavior. The nil-input path was already handled correctly. Signed-off-by: NirBarak-RecoLabs <nirb@recolabs.ai>
1 parent 5b44956 commit 42e7b4d

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

functions/string_funcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func fnSplit(args []any, _ any) (any, error) {
424424
}
425425
s, ok := args[0].(string)
426426
if !ok {
427-
return nil, &evaluator.JSONataError{Code: "T0410", Message: "$split: argument 1 must be a string"}
427+
return nil, nil
428428
}
429429
if len(args) < 2 {
430430
return nil, &evaluator.JSONataError{Code: "D3006", Message: "$split: requires at least 2 arguments"}

testdata/groups/function-split/case016.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"expr": "$split(12345, 3)",
33
"dataset": null,
44
"bindings": {},
5-
"code": "T0410"
5+
"undefinedResult": true
66
}

testdata/groups/function-split/case017.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"expr": "$split(12345)",
33
"dataset": null,
44
"bindings": {},
5-
"code": "T0410"
5+
"undefinedResult": true
66
}

0 commit comments

Comments
 (0)