Splunk Search
Highlighted

Internal Server Error trying to retrieve search results from custom module

Explorer

When my module tries to retrieve results from a search launched by a user, it produces this error:

GET http://localhost:8000/en-US/module/system/Splunk.Module.[module_name]/render?sid=[job_id]&client_app... 500 (Internal Server Error)

I believe it's being caused by a line in the python script in generateResults():

job = splunk.search.getJob(sid, sessionKey=cherrypy.session['sessionKey'])

I'm running Splunk 4.2.2

Any help is appreciated

EDIT:
This is the entire error:

2011-07-25 09:50:21,400 DEBUG [4e2d749d611ec1530] cplogging:55 - [25/Jul/2011:09:50:21] HTTP Traceback (most recent call last):

File "/Applications/splunk/lib/python2.6/site-packages/cherrypy/
cprequest.py", line 606, in respond

cherrypy.response.body = self.handler()

File "/Applications/splunk/lib/python2.6/site-packages/cherrypy/cpdispatch.py", line 25, in _call_

return self.callable(self.args, *self.kwargs)

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/routes.py", line 320, in default

return route.target(self, *kw)

File "", line 1, in

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 38, in rundecs

return fn(
a, *kw)

File "", line 1, in

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 106, in check

return fn(self, *a, *
kw)

File "", line 1, in

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 155, in validate
ip

return fn(self, a, *kw)

File "", line 1, in

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 290, in preformssocheck

return fn(self, a, *kw)

File "", line 1, in

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 327, in checklogin

return fn(self, a, *kw)

File "", line 1, in

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 348, in handle
exceptions

return fn(self, a, *kw)

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/controllers/module.py", line 62, in renderModule

return util.setcachelevel('etag', pageContent)

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/util.py", line 620, in setcachelevel

if applyetag(response):

File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/util.py", line 577, in apply
etag

hash.update(contentstring)

TypeError: update() argument 1 must be string or read-only buffer, not int

EDIT2: I've tried a few other things...

result = os.popen('curl -u admin:changeme -k https://localhost:8089/services/search/jobs/'+jobId+'/results/').read()

returns an empty string when used in the module; the equivalent works in a shell

return httplib2.Http().request('https://localhost:8089/services/search/jobs'+jobId+'/results/', 'POST', headers={'Authorization': 'Splunk %s' % sKey})

gives me the above error when used in the module; works in the python interpreter

key = splunk.auth.getSessionKey('admin', 'changeme')

my_job = splunk.search.dispatch('search [terms]', namespace='search')

also gives me the above error when used in the module; works in the python interpreter

Highlighted

Re: Internal Server Error trying to retrieve search results from custom module

Splunk Employee
Splunk Employee

I need more information, such as the specific error in web_service.log and more information on what the module is trying to do.

0 Karma
Highlighted

Re: Internal Server Error trying to retrieve search results from custom module

Explorer

The whole traceback is too big to fit here, but it starts with:
File "/Applications/splunk/lib/python2.6/site-packages/cherrypy/_cprequest.py", line 606, in respond
cherrypy.response.body = self.handler()

and ends with:
File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/util.py", line 577, in apply_etag
hash.update(contentstring)
TypeError: update() argument 1 must be string or read-only buffer, not int

At the moment, I'm just trying to retrieve search results

I used this example: splunk-base.splunk.com/answers/6666/how-do-you-create-custom-modules

0 Karma
Highlighted

Re: Internal Server Error trying to retrieve search results from custom module

Explorer

I'm also subclassing from the DispatchModule, if that helps

0 Karma
Highlighted

Re: Internal Server Error trying to retrieve search results from custom module

Explorer

I get the same error when I do this, after authorizing and given "sKey" and launching a search with the id "jobId":

httplib2.Http().request('https://localhost:8089/services/search/jobs'+jobId+'/results/', 'POST', headers={'Authorization': 'Splunk %s' % sKey})

0 Karma
Highlighted

Re: Internal Server Error trying to retrieve search results from custom module

Explorer

Figured it out.. dumb Python mistake. Needed to cast my return variable to a string first, as it expects a string. Didn't realize the error message was referring to that.

View solution in original post

0 Karma