-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
BugSomething isn't workingSomething isn't working
Description
Describe the bug
In the definition of a step in a workflow, if you create a parameter with the key "key", for example a POST in a WebHook:
steps:
- name: webhook
provider:
type: webhook
config: "{{ config }}"
with:
url: https://test/test
method: POST
body:
key: ALERT
host: "{{alert.service}}"
time: "{{alert.lastReceived}}"
source: "{{alert.source}}"
message: "{{alert.description}}"
The data of the POST body will be: "ALERT" and not a JSON with the keys: key, host, time, source and message.
This is because in parse_provider_parameters:
Lines 464 to 486 in cfcf490
def parse_provider_parameters(provider_parameters: dict) -> dict: | |
parsed_provider_parameters = {} | |
for parameter in provider_parameters: | |
if keyword.iskeyword(parameter): | |
# add suffix _ to provider parameters if it's a reserved keyword in python | |
parameter_name = parameter + "_" | |
else: | |
parameter_name = parameter | |
if isinstance(provider_parameters[parameter], (str, list, int, bool)): | |
parsed_provider_parameters[parameter_name] = provider_parameters[ | |
parameter | |
] | |
elif isinstance(provider_parameters[parameter], dict): | |
try: | |
parsed_provider_parameters[parameter_name] = StepProviderParameter( | |
**provider_parameters[parameter] | |
) | |
except Exception: | |
# It could be a dict/list but not of ProviderParameter type | |
parsed_provider_parameters[parameter_name] = provider_parameters[ | |
parameter | |
] | |
return parsed_provider_parameters |
if the parameter is a dictionary it attempt to converted it to a StepProviderParameter and this works if the dict has a key with the name "key" because in the definition of de pydantic model "key" is the only required parameter
keep/keep/step/step_provider_parameter.py
Lines 1 to 7 in cfcf490
from pydantic import BaseModel | |
class StepProviderParameter(BaseModel): | |
key: str # the key to render | |
safe: bool = False # whether to validate this key or fail silently ("safe") | |
default: str | int | bool = None # default value if this key doesn't exist |
dosubot
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working