[🐛 Bug]: Keep's keep.dictget() function parsing has an issue
Describe the bug
When a workflow using keep.dictget('{{alert}}', 'some_field', 'unknown') function is run on the alert with description="Hello ('Hola') everyone. How are you all doing?", the workflow fails. Tried using double quotes around the dictget params but it didn't work.
To Reproduce Steps to reproduce the behavior:
- Add an alert with the mentioned description
- Add a workflow with the following configuration
steps:
- name: console-step provider: type: console config: "{{ providers.default-console }}" with: message: keep.dictget('{{alert}}', 'some_field', 'unknown')
- Execute the workflow on the inserted alert
Expected behavior The workflow should run successfully.
Screenshots
Root cause: The issue is originating from here: https://github.com/keephq/keep/blob/main/keep/iohandler/iohandler.py#L96 The substring ') is causing the issue because when it processes the quote, keep considers it as terminating character.
This parsing bug is caused by how the workflow engine handles quoted strings with parentheses in function arguments. The parser in iohandler.py treats a closing parenthesis inside a quoted string as the end of the argument, which leads to premature termination and parsing errors—especially with values like "Hello ('Hola') everyone. How are you all doing?" in your alert description. Quoting the parameters doesn't help because the underlying logic isn't robust enough to handle these edge cases [source].
There aren't any documented workarounds or fixes for this issue, and no recent pull requests address it. For now, you might be able to avoid the bug by ensuring your string arguments do not contain parentheses immediately after quotes, or by sanitizing alert descriptions before passing them to workflow functions. A more reliable fix would require improvements to the parser itself, such as using a state machine or leveraging Python's built-in parsing modules.
Let me know if you need help exploring alternative approaches or want more details about the parsing logic!
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other