splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
687 stars 369 forks source link

Searchcommand does not support empty body anymore in v1.6.15 #376

Closed knibbl closed 2 years ago

knibbl commented 3 years ago

Describe the bug Empty body in function _execute_chunk_v2 is not supported anymore. In previous versions we had an EventingCommand that produced results even when the body was empty. After upgrading to 1.6.15 this doesn't work anymore, see code below.

v1.6.14:

                if len(mv_fieldnames) == 0:
                    for values in reader:
                        yield OrderedDict(izip(fieldnames, values))
                else:
                    for values in reader:
                        record = OrderedDict()
                        for fieldname, value in izip(fieldnames, values):
                            if fieldname.startswith('__mv_'):
                                if len(value) > 0:
                                    record[mv_fieldnames[fieldname]] = self._decode_list(value)
                            elif fieldname not in record:
                                record[fieldname] = value
                        yield record

v1.6.15:

            if len(body) <= 0:
                return

This issue was very hard to debug for us, because no error was thrown when our custom command gets executed. It seems like the execution of our command was successful, because of the return statement. If this behavior is expected an error message would be helpful for debugging.

Removing line 968 from version 1.6.15 would solve the issue.

To Reproduce Steps to reproduce the behavior:

| customcmd This produced results in 1.6.14 but not in 1.6.15 anymore. A workaround was: | stats count | customcdm

Expected behavior Deliver results even without input.

Logs or Screenshots

Splunk (please complete the following information):

fantavlik commented 2 years ago

Thanks @knibbl we believe this has been addressed in https://github.com/splunk/splunk-sdk-python/pull/402 - we are preparing a 1.6.17 release now with this fix.