Splunk Streaming Command dict_reader.py attempts to iterate over none
Hey guys,
For some reason Splunk trys to iterate over none and throws a TypeError: 'NoneType' object is not iterable in https://github.com/splunk/splunk-sdk-python/blob/master/splunklib/searchcommands/splunk_csv/dict_reader.py#L38. This is only reproducible in in certain environments it seems (happens in our production distributed cluster(s) but not in local test VMs). This causes the command to still execute but throws an error on the screen cause Splunk sent it no data.
I understand that it shouldn't do this yet still throws the error even though it enriches the data correctly. We were able to duplicate this occurrence with both a custom command and with the countmatches example code in our production testbed
My code inspection indicates you've discovered a bug and I have what I think is a fix. This:
try:
self._fieldnames = self.reader.next()
except StopIteration:
pass
Should be:
try:
self._fieldnames = self.reader.next()
except StopIteration:
self._fieldnames = []
Given that you've got a repro, I'll ask: Can you give this change a try?
I'll be able to give it a try on Monday when I'm in our office and can put the code on the server to verify this fixes it. Thanks
You're welcome.
Thanks for reporting this Kevin! On Fri, Jul 10, 2015 at 3:01 PM David Noble [email protected] wrote:
You're welcome.
— Reply to this email directly or view it on GitHub https://github.com/splunk/splunk-sdk-python/issues/110#issuecomment-120538799 .
Course. Thanks for such quick help and for directing me where to get this kinda thing reported @glennblock
@David-Noble-at-work @glennblock The suggested fix to the API code appears to be working on the Splunk 6 search heads. Thanks guys!
w00t!
On Mon, Jul 13, 2015 at 12:57 PM Kevin Kirsche [email protected] wrote:
@David-Noble-at-work https://github.com/David-Noble-at-work @glennblock https://github.com/glennblock The suggested fix to the API code appears to be working on the Splunk 6 search heads. Thanks guys!
— Reply to this email directly or view it on GitHub https://github.com/splunk/splunk-sdk-python/issues/110#issuecomment-121037638 .
Fixed in v1.4.0 which we just released!