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

Searchcommand does not support empty body anymore in v1.6.15

Open knibbl opened this issue 5 years ago • 1 comments

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):

  • Version: latest
  • OS: CentOS8
  • Deployment: Distributed Env

knibbl avatar May 04 '21 15:05 knibbl

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.

fantavlik avatar Nov 01 '21 16:11 fantavlik