<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Internal Server Error trying to retrieve search results from custom module in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47241#M11278</link>
    <description>&lt;P&gt;I'm also subclassing from the DispatchModule, if that helps&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jul 2011 16:46:28 GMT</pubDate>
    <dc:creator>achung12</dc:creator>
    <dc:date>2011-07-22T16:46:28Z</dc:date>
    <item>
      <title>Internal Server Error trying to retrieve search results from custom module</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47238#M11275</link>
      <description>&lt;P&gt;When my module tries to retrieve results from a search launched by a user, it produces this error:&lt;BR /&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;GET &lt;A href="http://localhost:8000/en-US/module/system/Splunk.Module.%5Bmodule_name%5D/render?sid=%5Bjob_id%5D&amp;amp;client_app=%5Bapp_name%5D" target="_blank"&gt;http://localhost:8000/en-US/module/system/Splunk.Module.[module_name]/render?sid=[job_id]&amp;amp;client_app=[app_name]&lt;/A&gt; 500 (Internal Server Error)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I believe it's being caused by a line in the python script in generateResults():&lt;BR /&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;job = splunk.search.getJob(sid, sessionKey=cherrypy.session['sessionKey'])&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I'm running Splunk 4.2.2&lt;/P&gt;

&lt;P&gt;Any help is appreciated&lt;/P&gt;

&lt;P&gt;EDIT:&lt;BR /&gt;
This is the entire error:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;2011-07-25 09:50:21,400 DEBUG  [4e2d749d611ec1530] &lt;EM&gt;cplogging:55 - [25/Jul/2011:09:50:21] HTTP Traceback (most recent call last):&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/cherrypy/_cprequest.py", line 606, in respond&lt;BR /&gt;&lt;BR /&gt;
    cherrypy.response.body = self.handler()&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/cherrypy/_cpdispatch.py", line 25, in __call&lt;/EM&gt;_&lt;BR /&gt;&lt;BR /&gt;
    return self.callable(*self.args, **self.kwargs)&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/routes.py", line 320, in default&lt;BR /&gt;&lt;BR /&gt;
    return route.target(self, **kw)&lt;BR /&gt;&lt;BR /&gt;
  File "&lt;STRING&gt;", line 1, in &lt;LAMBDA&gt;&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 38, in rundecs&lt;BR /&gt;&lt;BR /&gt;
    return fn(*a, **kw)&lt;BR /&gt;&lt;BR /&gt;
  File "&lt;STRING&gt;", line 1, in &lt;LAMBDA&gt;&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 106, in check&lt;BR /&gt;&lt;BR /&gt;
    return fn(self, *a, **kw)&lt;BR /&gt;&lt;BR /&gt;
  File "&lt;STRING&gt;", line 1, in &lt;LAMBDA&gt;&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 155, in validate_ip&lt;BR /&gt;&lt;BR /&gt;
    return fn(self, *a, **kw)&lt;BR /&gt;&lt;BR /&gt;
  File "&lt;STRING&gt;", line 1, in &lt;LAMBDA&gt;&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 290, in preform_sso_check&lt;BR /&gt;&lt;BR /&gt;
    return fn(self, *a, **kw)&lt;BR /&gt;&lt;BR /&gt;
  File "&lt;STRING&gt;", line 1, in &lt;LAMBDA&gt;&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 327, in check_login&lt;BR /&gt;&lt;BR /&gt;
    return fn(self, *a, **kw)&lt;BR /&gt;&lt;BR /&gt;
  File "&lt;STRING&gt;", line 1, in &lt;LAMBDA&gt;&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/decorators.py", line 348, in handle_exceptions&lt;BR /&gt;&lt;BR /&gt;
    return fn(self, *a, **kw)&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/controllers/module.py", line 62, in renderModule&lt;BR /&gt;&lt;BR /&gt;
    return util.set_cache_level('etag', pageContent)&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/util.py", line 620, in set_cache_level&lt;BR /&gt;&lt;BR /&gt;
    if apply_etag(response):&lt;BR /&gt;&lt;BR /&gt;
  File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/util.py", line 577, in apply_etag&lt;BR /&gt;&lt;BR /&gt;
    hash.update(contentstring)&lt;BR /&gt;&lt;BR /&gt;
TypeError: update() argument 1 must be string or read-only buffer, not int&lt;/LAMBDA&gt;&lt;/STRING&gt;&lt;/LAMBDA&gt;&lt;/STRING&gt;&lt;/LAMBDA&gt;&lt;/STRING&gt;&lt;/LAMBDA&gt;&lt;/STRING&gt;&lt;/LAMBDA&gt;&lt;/STRING&gt;&lt;/LAMBDA&gt;&lt;/STRING&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;EDIT2: I've tried a few other things...  &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;result = os.popen('curl -u admin:changeme -k &lt;A href="https://localhost:8089/services/search/jobs/'+jobId+'/results/').read(" target="_blank"&gt;https://localhost:8089/services/search/jobs/'+jobId+'/results/').read(&lt;/A&gt;)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;returns an empty string when used in the module; the equivalent works in a shell&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;return httplib2.Http().request('&lt;A href="https://localhost:8089/services/search/jobs'+jobId+'/results/" target="_blank"&gt;https://localhost:8089/services/search/jobs'+jobId+'/results/&lt;/A&gt;', 'POST', headers={'Authorization': 'Splunk %s' % sKey})&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;gives me the above error when used in the module; works in the python interpreter&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;key = splunk.auth.getSessionKey('admin', 'changeme')&lt;BR /&gt;&lt;BR /&gt;
my_job = splunk.search.dispatch('search [terms]', namespace='search')&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;also gives me the above error when used in the module; works in the python interpreter&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:45:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47238#M11275</guid>
      <dc:creator>achung12</dc:creator>
      <dc:date>2020-09-28T09:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error trying to retrieve search results from custom module</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47239#M11276</link>
      <description>&lt;P&gt;I need more information, such as the specific error in web_service.log and more information on what the module is trying to do.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 16:08:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47239#M11276</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2011-07-22T16:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error trying to retrieve search results from custom module</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47240#M11277</link>
      <description>&lt;P&gt;The whole traceback is too big to fit here, but it starts with:&lt;BR /&gt;
File "/Applications/splunk/lib/python2.6/site-packages/cherrypy/_cprequest.py", line 606, in respond&lt;BR /&gt;
    cherrypy.response.body = self.handler()&lt;/P&gt;

&lt;P&gt;and ends with:&lt;BR /&gt;
File "/Applications/splunk/lib/python2.6/site-packages/splunk/appserver/mrsparkle/lib/util.py", line 577, in apply_etag&lt;BR /&gt;
    hash.update(contentstring)&lt;BR /&gt;
TypeError: update() argument 1 must be string or read-only buffer, not int&lt;/P&gt;

&lt;P&gt;At the moment, I'm just trying to retrieve search results&lt;/P&gt;

&lt;P&gt;I used this example: splunk-base.splunk.com/answers/6666/how-do-you-create-custom-modules&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 16:26:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47240#M11277</guid>
      <dc:creator>achung12</dc:creator>
      <dc:date>2011-07-22T16:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error trying to retrieve search results from custom module</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47241#M11278</link>
      <description>&lt;P&gt;I'm also subclassing from the DispatchModule, if that helps&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 16:46:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47241#M11278</guid>
      <dc:creator>achung12</dc:creator>
      <dc:date>2011-07-22T16:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error trying to retrieve search results from custom module</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47242#M11279</link>
      <description>&lt;P&gt;I get the same error when I do this, after authorizing and given "sKey" and launching a search with the id "jobId":&lt;BR /&gt;&lt;BR /&gt;
httplib2.Http().request('&lt;A href="https://localhost:8089/services/search/jobs'+jobId+'/results/"&gt;https://localhost:8089/services/search/jobs'+jobId+'/results/&lt;/A&gt;', 'POST', headers={'Authorization': 'Splunk %s' % sKey})&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47242#M11279</guid>
      <dc:creator>achung12</dc:creator>
      <dc:date>2011-07-25T13:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error trying to retrieve search results from custom module</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47243#M11280</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2011 18:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Internal-Server-Error-trying-to-retrieve-search-results-from/m-p/47243#M11280</guid>
      <dc:creator>achung12</dc:creator>
      <dc:date>2011-07-25T18:50:43Z</dc:date>
    </item>
  </channel>
</rss>

