logstash-plugins / logstash-codec-json

Apache License 2.0
23 stars 29 forks source link

json decoder should raise error when input is invalid #11

Closed vqng closed 9 years ago

vqng commented 9 years ago

sample log that is not valid json

1434701105.727    86 127.0.0.1 TCP_MISS/204 316 GET http://b.scorecardresearch.com/b? - HIER_DIRECT/184.51.147.121 -
1434701105.728    34 127.0.0.1 TCP_MISS/200 3929 GET http://assetscdn.paytm.com/images/catalog/product/C/CM/CMPLXDMG_MMXA94WHTWTEARMSCR_NULL_NULL/210x210/2.jpeg - HIER_DIRECT/157.238.74.178 image/jpeg

The json decoding process should fail but it doesn't. This issue was originally raised at https://github.com/elastic/logstash-forwarder/issues/293#issuecomment-115180966

driskell commented 9 years ago

Seems the JSON decoder actually succeeds and returns a float containing "1434701105.727". Because this is not a Hash it causes an exception when Logstash tries to create a new event for it.

The decoder should probably check the result is a Hash and raise a parse error if not.

jlintz commented 9 years ago

We've seen this as well since upgrading to 1.5 where normally we were able to set the codec to JSON on the lumberjack input and it would fail back fine to plaintext , it's now crashing on certain inputs, haven't been able to grab which lines are causing the issue yet

andrewvc commented 9 years ago

@jlintz @driskell this should be fixed in the latest release of this plugin 1.1.0. Try upgrading and see if that helps you out :)

Please reopen this ticket if you have any further issues!