Skip to content

Empty accelerated fields leads to TypeError #677

@seiimonn

Description

@seiimonn

Describe the bug

def __getitem__(self, item):
        res = Collection.__getitem__(self, item)
        for k, v in res.content.items():
            if "accelerated_fields" in k:
                res.content[k] = json.loads(v)
        return res

This code breaks if v is not a valid JSON string.
As there is no way to remove an acceleration other than setting it to empty, this is a typical case.

To Reproduce
Steps to reproduce the behaviour:

c.kvstore.create("test")
collection = c.kvstore["test"]
collection.update_accelerated_field("test", {"test": 1})
collection = c.kvstore["test"]
collection.update_accelerated_field("test", "")
collection = c.kvstore["test"]

Expected behaviour
Rather than an exception, the empty string is used as the value.

If I am allowed to dream, splunkd should provide a mechanism to remove accelerations and field configurations cleanly. However, this bug should still be fixed, as we never know what administrators might write in .conf files.

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