Skip to content

KVStoreCollection using wrong argument in "update_index" #497

Closed
@seiimonn

Description

@seiimonn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions