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

jsonpath library unmaintained? #47

Closed
rustycl0ck opened this issue Jul 29, 2020 · 4 comments · Fixed by #74
Closed

jsonpath library unmaintained? #47

rustycl0ck opened this issue Jul 29, 2020 · 4 comments · Fixed by #74

Comments

@rustycl0ck
Copy link
Member

The jsonpath library in use (github.com/kawamuray/jsonpath) has not been updated in the past 5 years and thus, looks unmaintained. Maybe we should consider moving to k8s.io/client-go/util/jsonpath (or any other up to date library), which is expected to be well maintained and has nice documentation too - https://kubernetes.io/docs/reference/kubectl/jsonpath.

@mirceaulinic
Copy link

To add up to this, run into some bug when trying to use this exporter:

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

goroutine 1 [running]:
github.com/kawamuray/jsonpath.take1ByteSlice(0xc0000e5240, 0xa, 0xc0001a8af0, 0x9, 0x9, 0x0, 0x0)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/expression.go:401 +0x99
github.com/kawamuray/jsonpath.take2ByteSlice(0xc0000e5240, 0xa, 0x9, 0xc0003ce600, 0xc0000e54d0, 0x1, 0x0, 0x0, 0x0, 0x0)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/expression.go:408 +0x9d
github.com/kawamuray/jsonpath.evaluatePostFix(0xc0001b4dc0, 0x7, 0x8, 0xc0000e5418, 0xc0000e54f8, 0x0, 0x0, 0x0)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/expression.go:198 +0x1956
github.com/kawamuray/jsonpath.(*exprBucket).evaluate(0xc0000e56c8, 0xc0001a6488, 0x10, 0x203000)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/eval.go:305 +0x43e
github.com/kawamuray/jsonpath.(*query).trySpillOver(0xc0000aa750)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/eval.go:162 +0x156
github.com/kawamuray/jsonpath.pathEndValue(0xc0000aa750, 0xc000120c60, 0xc00015c010, 0xa49700)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/eval.go:282 +0x24f
github.com/kawamuray/jsonpath.(*Eval).Iterate(0xc000120c60, 0xc000394150, 0xffffffffffffff01)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/eval.go:102 +0x35d
github.com/kawamuray/jsonpath.(*Eval).Next(0xc000120c60, 0xc00058a240, 0x3e01)
	/home/mircea/go/pkg/mod/github.com/kawamuray/[email protected]/eval.go:140 +0x3f
github.com/prometheus-community/json_exporter/jsonexporter.(*ValueScraper).forTargetValue(0xc000190f80, 0xc0003aa000, 0x1f4a, 0x3e00, 0xc0000e5a78, 0x0, 0x0)
	/home/mircea/git/public/json_exporter/jsonexporter/scraper.go:64 +0xc3
github.com/prometheus-community/json_exporter/jsonexporter.(*ObjectScraper).Scrape(0xc000180920, 0xc0003aa000, 0x1f4a, 0x3e00, 0xc000186060, 0x0, 0x0)
	/home/mircea/git/public/json_exporter/jsonexporter/scraper.go:169 +0x89
github.com/prometheus-community/json_exporter/jsonexporter.(*Collector).Collect(0xc00018cfc0, 0xc000186060)
	/home/mircea/git/public/json_exporter/jsonexporter/collector.go:91 +0xe5
github.com/prometheus-community/json_exporter/harness.(*exporter).main(0xc000186050, 0xc000196160)
	/home/mircea/git/public/json_exporter/harness/exporter.go:85 +0x3be
github.com/urfave/cli.HandleAction(0x956e20, 0xc000190b40, 0xc000196160, 0x0, 0x0)
	/home/mircea/go/pkg/mod/github.com/urfave/[email protected]/app.go:528 +0x127
github.com/urfave/cli.(*App).Run(0xc0001f21c0, 0xc0000c0000, 0x7, 0x7, 0x0, 0x0)
	/home/mircea/go/pkg/mod/github.com/urfave/[email protected]/app.go:288 +0x5fc
github.com/prometheus-community/json_exporter/harness.Main(0xc0001e1c00)
	/home/mircea/git/public/json_exporter/harness/main.go:79 +0x5d
main.main()
	/home/mircea/git/public/json_exporter/json_exporter.go:25 +0xdf

This is when trying to parse JSON documents that have (as valid as it can be) null fields (e.g., field: null). I'd have reported this to https://github.com/kawamuray/jsonpath but even the Issues sections is disabled.

@rustycl0ck
Copy link
Member Author

I just hit another issue. eval.Iterate() does not work. It always returns empty *Results

@SuperQ
Copy link
Contributor

SuperQ commented Aug 3, 2020

Seems like a good idea to me. @rustycl0ck Are you interested in doing this work?

@rustycl0ck
Copy link
Member Author

Yes, I can take this up. But I'm not sure which library to replace with, right now. Currently I have just been working on #14 with the current library. I'll send a PR for that and can work on replacing the library later.
I think the other issues (namely #33 #44 #45) are more important and urgent to make this exporter actually usable. So I think this library upgrade can be postponed since it is not making the current situation any worse right now.

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

Successfully merging a pull request may close this issue.

3 participants