pteich / elastic-query-export

🚚 Export Data from ElasticSearch to CSV/JSON using a Lucene Query (e.g. from Kibana) or a raw JSON Query string
MIT License
89 stars 18 forks source link

null pointer #12

Closed realjax closed 2 years ago

realjax commented 2 years ago

Trying to output to json format results in this error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x1365545]

goroutine 1 [running]:
github.com/pteich/elastic-query-export/formats.JSON.Run({0xc000194010, 0xc0001ee000}, {0x14892f8, 0xc000098580}, 0xc0000a6600)
    /Users/peter/github/elastic-query-export/formats/json.go:23 +0x65
github.com/pteich/elastic-query-export/export.Run({0x1489560, 0xc000022340}, 0xc000160000)
    /Users/peter/github/elastic-query-export/export/export.go:159 +0x15b2
main.main.func1(0xc000090000, {0x1387980, 0xc000160000})
    /Users/peter/github/elastic-query-export/main.go:38 +0x3a
github.com/pteich/configstruct.(*Command).ParseAndRun(0xc000092050, {0xc000010070, 0x0, 0x0}, {0x0, 0x142578b, 0x72})
    /Users/peter/go/pkg/mod/github.com/pteich/configstruct@v1.4.2/commands.go:64 +0xe8
main.main()
    /Users/peter/github/elastic-query-export/main.go:43 +0x187

Notes:

pteich commented 2 years ago

I can reproduce it locally and fixed it with #13 Thanks for reporting it!

pteich commented 2 years ago

Additional note: The JSON output exports one document as JSON per line. So the file itself won't be valid JSON.