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

Splunk Streaming Command dict_reader.py attempts to iterate over none

Open kkirsche opened this issue 11 years ago • 8 comments

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

kkirsche avatar Jul 10 '15 21:07 kkirsche

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?

David-Noble-at-work avatar Jul 10 '15 21:07 David-Noble-at-work

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

kkirsche avatar Jul 10 '15 22:07 kkirsche

You're welcome.

David-Noble-at-work avatar Jul 10 '15 22:07 David-Noble-at-work

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 .

glennblock avatar Jul 11 '15 00:07 glennblock

Course. Thanks for such quick help and for directing me where to get this kinda thing reported @glennblock

kkirsche avatar Jul 11 '15 00:07 kkirsche

@David-Noble-at-work @glennblock The suggested fix to the API code appears to be working on the Splunk 6 search heads. Thanks guys!

kkirsche avatar Jul 13 '15 19:07 kkirsche

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 .

glennblock avatar Jul 13 '15 20:07 glennblock

Fixed in v1.4.0 which we just released!

shakeelmohamed avatar Aug 05 '15 00:08 shakeelmohamed