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

KVStoreCollection using wrong argument in "update_index"

Open seiimonn opened this issue 4 years ago • 3 comments

Describe the bug When updating the index of a collection the following error is given:

splunklib.binding.HTTPError: HTTP 400 Bad Request -- Argument "index.ho1" is not supported by this handler.

To Reproduce Steps to reproduce the behavior:

>>> import splunklib.client as client
>>> c = client.connect()
>>> c.kvstore.create("example_collection")
>>> c.kvstore["example_collection"].update_index("get_fast",{"important_field": 1})

Expected behavior Update of accelerated fields for collection.

Logs or Screenshots

>>> c.kvstore["example_collection"].update_index("get_fast",{"important_field": 1})
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.11) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/backend/src/lib/splunklib/client.py", line 3622, in update_index
    return self.post(**kwargs)
  File "/app/backend/src/lib/splunklib/client.py", line 1047, in post
    return super(Entity, self).post(path_segment, owner=owner, app=app, sharing=sharing, **query)
  File "/app/backend/src/lib/splunklib/client.py", line 852, in post
    return self.service.post(path, owner=owner, app=app, sharing=sharing, **query)
  File "/app/backend/src/lib/splunklib/binding.py", line 289, in wrapper
    return request_fun(self, *args, **kwargs)
  File "/app/backend/src/lib/splunklib/binding.py", line 70, in new_f
    val = f(*args, **kwargs)
  File "/app/backend/src/lib/splunklib/binding.py", line 769, in post
    response = self.http.post(path, all_headers, **query)
  File "/app/backend/src/lib/splunklib/binding.py", line 1262, in post
    return self.request(url, message)
  File "/app/backend/src/lib/splunklib/binding.py", line 1282, in request
    raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 400 Bad Request -- Argument "index.get_fast" is not supported by this handler.

Splunk (please complete the following information):

  • Version: 9.0.2
  • OS: Ubuntu 20.04 LTS
  • Deployment: tested on single-instance

SDK (please complete the following information):

  • Version: 1.6.19
  • Language Runtime Version: Python 3.7
  • OS: Ubuntu 20.04 LTS

Additional context I guess that the issue is based on index vs accelerations. An acceleration in a collection is an index on the underlying MongoDB. Patching the line https://github.com/splunk/splunk-sdk-python/blob/master/splunklib/client.py#L3724 to kwargs['accelerated_fields.' + name] = value if isinstance(value, six.string_types) else json.dumps(value) fixes the issue.

seiimonn avatar Nov 18 '22 11:11 seiimonn

Hi @seiimonn we are looking into the issue and will get back to you soon.

ashah-splunk avatar Nov 29 '22 09:11 ashah-splunk

Hi @seiimonn , support for accelerated_fields is added in SDK and it will be available in the next release.

akaila-splunk avatar Jan 31 '23 06:01 akaila-splunk

@seiimonn request you to pull the latest SDK release v1.7.3 with the added support and let us know in case of any issue. Thanks!

ashah-splunk avatar Feb 13 '23 06:02 ashah-splunk