Splunk Dev

Why WebFramework's responses with a non-200 HTTP Status Code always return the same, post-6.2.x?

CynthiaMhav
Explorer

Before the Splunk Enterprise version 6.2.x (e.g. in 6.1.x) I could still write in WebFramework (Django -based one), to return HTTP response with Status Code of 400, 404, or 500, with a custom message body.

I could do this by, either using Django Framework's ready "HttpResponseBadRequest", "HttpRequestNotFound", and "HttpResponseServerError" -objects, or using the plain "HttpResponse" -object specifying the Status Code as a parameter.

So I could create for example a 500-Code message with a message "Subsystem X failed - request not delivered", should the program logic fail accordingly. I could even use the Django's HTTP-Exception shortcuts (e.g. 'raise Http404("These drones aren't what you are looking for.")'.

Since 6.2.x the HttpRequest with a Status Code of 200 (thankfully) works fine - else it'd be impossible to code by Web Framework anymore... But any other Status Code seems to get overwritten into a default XML message (apparently defined in *$SPLUNK_ROOT/lib/python2.7/site-packages/splunk/appserver/mrsparkle/controllers.proxy.py** ... I didn't have time yet, to reverse engineer that issue further in-code)*. This makes it impossible to return custom 404 pages, or error messages/reasons, effectively breaking any old javascript that relied on these...

So I have two options to go with:
- Either I refactor all serverside error messages to return Http Status "200 - OK", and refactor also all client-side code to expect ONLY 200 code, parsing it's content... but this is a lot less error resilient (than checking the Status Code), and makes the server-side code rather ambiguous.
- Or I overwrite the respective CherryPy module, that makes this change. I'd rather not go on with this, as it could produce Unforseen Consequences™, and has to be re-implemented on each version update...

Any information on whether this was an intended change, or not, and what is the likely version for it to be "fixed" (if will), would be really much appreciated.

dfoster_splunk
Splunk Employee
Splunk Employee

I think this is a bug. I have filed it internally as SPL-97569 and instructed that this thread be updated when the ticket is completed. I have no ETA.

0 Karma

CynthiaMhav
Explorer

Thank you, a lot. 🙂 This is a rather crippling bug on any javascript that relied on the response bodies (in addition to status codes)... but then again, this laying around a few months now (unfortunately I had no time to report it earlier.. had hurries everywhere) makes it look like not too many use the Django side in-depth. 😞

0 Karma

dfoster_splunk
Splunk Employee
Splunk Employee

Django is receiving less active dev attention now than in the past. Migrating to Simple XML + HTML panels + JS/CSS extensions is a more stable path moving forward if you have resources to make such a transition. -- Much of our existing docs are not up-to-date on this point.

0 Karma

CynthiaMhav
Explorer

We're currently using both Django and SimpleXML (in an unintended/ad-hoc way, in order to add some non-indexed data to the non-dashboard views, i.e. RDBMS data that's constantly fluctuating by relations - so less suitable for indexing..). Good to know, though. Thanks again. 🙂

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...