Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge in go-jmespath / jp panics when parameters are not JSON objects #72

Open
n9 opened this issue Aug 25, 2022 · 1 comment
Open

merge in go-jmespath / jp panics when parameters are not JSON objects #72

n9 opened this issue Aug 25, 2022 · 1 comment

Comments

@n9
Copy link

n9 commented Aug 25, 2022

echo {"message": "foo"} | jp "merge({message: message}, contextMap)"
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/jmespath/go-jmespath.jpfMerge({0xc00004ec20, 0x2, 0xc00000e3c0})
        /Users/jamessar/Source/go/pkg/mod/github.com/jmespath/go-jmespath@v0.4.0/functions.go:520 +0x197
github.com/jmespath/go-jmespath.(*functionCaller).CallFunction(0x70e1c0, {0xc00000e3c0, 0x5}, {0xc00004ec20, 0x2, 0x2}, 0xc000006060)
        /Users/jamessar/Source/go/pkg/mod/github.com/jmespath/go-jmespath@v0.4.0/functions.go:401 +0x264
github.com/jmespath/go-jmespath.(*treeInterpreter).Execute(0xc000006060, {0x4, {0x707500, 0xc00004cfd0}, {0xc000020420, 0x2, 0x2}}, {0x711c40, 0xc0000769f0})
        /Users/jamessar/Source/go/pkg/mod/github.com/jmespath/go-jmespath@v0.4.0/interpreter.go:77 +0x1f35
github.com/jmespath/go-jmespath.Search({0xc00000e3c0, 0x25}, {0x711c40, 0xc0000769f0})
        /Users/jamessar/Source/go/pkg/mod/github.com/jmespath/go-jmespath@v0.4.0/api.go:48 +0x173
main.runMain(0xc000154000)
        /Users/jamessar/Source/jp/jp.go:105 +0x7d4
main.runMainAndExit(0xc000072a00)
        /Users/jamessar/Source/jp/jp.go:51 +0x19
github.com/urfave/cli.HandleAction({0x706800, 0x7482c0}, 0x25)
        /Users/jamessar/Source/go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:526 +0x50
github.com/urfave/cli.(*App).Run(0xc000152000, {0xc00004e3c0, 0x2, 0x2})
        /Users/jamessar/Source/go/pkg/mod/github.com/urfave/cli@v1.22.5/app.go:286 +0x625
main.main()
        /Users/jamessar/Source/jp/jp.go:47 +0x4a5
@b-enoit-be
Copy link

The behaviour I would expect when doing a merge(`{"a": 1}`, null) would be to get {"a": 1} as a result, as null, is a valid JSON object.

Or at least it works like that on the site: https://jmespath.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants