Skip to content

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

@n9

Description

@n9
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions