sherlock icon indicating copy to clipboard operation
sherlock copied to clipboard

json_decode() Errors

Open the-invisible-man opened this issue 12 years ago • 1 comments

An exception should be thrown if PHP fails to decode a json string. It's possible for ElasticSearch to return a bad string.

In ES one can insert a record as follows: curl -XPOST -d '{ field : "data"}'

When the correct way would be: curl -XPOST -d '{ "field" : "data"}'

Note the double quotes around the field name. ES accepts this and returns "ok", "true". When querying from the PHP client ES returns the faulty json string and the client isn't able to decode it, the program execution continues and stops with a 'Call to undefined method query() in Sherlock/Sherlock'

the-invisible-man avatar Aug 23 '13 13:08 the-invisible-man

Interesting, this is indeed bad behavior. Sherlock should definitely throw exceptions on json errors, rather than allowing execution to continue. I'll look into it later this week when I get a chance.

polyfractal avatar Aug 28 '13 01:08 polyfractal