splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

Error responses raise XML parse error

Open georgepsarakis opened this issue 11 years ago • 4 comments

The SDK handles all error responses with HTTP code <= 400 by raising a splunklib.binding.HTTPError exception as seen here.

In its turn HTTPError attempts to perform XML parsing on the response body. This results in a xml.etree.ElementTree.ParseError exception being raised in cases where the error response is JSON serialized and not in XML format and thus the error response details cannot be viewed.

You can reproduce it by attempting to create a search job with:

  • exec_mode=normal
  • output_mode=json
  • query=invalid_query

Based on the search example variables:

service.jobs.create("invalid_query", **{"exec_mode":"normal", "output_mode":"json")

georgepsarakis avatar May 27 '15 17:05 georgepsarakis

Thanks for reporting this @georgepsarakis - we think we know what might be causing this, and we'll take a look. As always, Pull Requests are welcome :)

itay avatar May 27 '15 18:05 itay

Hi @georgepsarakis we've made the fix on the develop branch with https://github.com/splunk/splunk-sdk-python/commit/e4aaca81bfe4420876a8305706298e75b9876973. This change will go out with the next release (once we add some tests), stay tuned

shakeelmohamed avatar Jun 04 '15 18:06 shakeelmohamed

Hi @georgepsarakis we've just released v1.4.0 that addresses this.

shakeelmohamed avatar Aug 05 '15 00:08 shakeelmohamed

@shakeelmohamed thanks for your response!

georgepsarakis avatar Aug 09 '15 06:08 georgepsarakis