You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Noticeable in trigger/id API calls. Payload-provided variables unspecified fields are initialised to default values, and variables are then completely substituting the playbook variables (playbook.PlaybookVariables.Merge(payload_variables) at the end of func MergeVariablesInPlaybook(playbook *cacao.Playbook, body []byte) (bool, string), in trigger_api.go).
Hence, variables inside the playbook will have their properties changed.
To Reproduce provide details logs and steps
To reproduce, you can add a print before trigger.execute(&playbook, context) in func (trigger *TriggerApi) ExecuteById(context *gin.Context) in trigger_api.go, and run the test func TestExecutionOfPlaybookByIdWithPayloadValidVariables(t *testing.T) in unittest/routes.trigger_api/trigger_api_test.go
Expected behavior
The variable in the playbook remains exactly the same except for the values provided by the properties in the payload-specified variables.
Additional context
As solution, we should implement a function that receiving a variable in input from a payload (not marshalled to a cacao.Variable object), marshals it in a cacao.Variable object but also taking into account the variable it will substitute the values of. This will also allow us to e.g. prevent payload-provided variables from overwriting the "external" property.
Then, we should also implement a property-by-property merge function for the cacao.Variables which accounts for initialisation-provided values, diffs between payload-provided and playbook-present variables, and prevents overwriting of meta properties e.g. bool, and const (modifying these fields should pertain to playbook editing tasks. It's surely not a within-execution task).
The text was updated successfully, but these errors were encountered:
Describe the bug
Noticeable in trigger/id API calls. Payload-provided variables unspecified fields are initialised to default values, and variables are then completely substituting the playbook variables (
playbook.PlaybookVariables.Merge(payload_variables)
at the end offunc MergeVariablesInPlaybook(playbook *cacao.Playbook, body []byte) (bool, string)
, intrigger_api.go
).Hence, variables inside the playbook will have their properties changed.
To Reproduce provide details logs and steps
To reproduce, you can add a print before
trigger.execute(&playbook, context)
infunc (trigger *TriggerApi) ExecuteById(context *gin.Context)
intrigger_api.go
, and run the testfunc TestExecutionOfPlaybookByIdWithPayloadValidVariables(t *testing.T)
inunittest/routes.trigger_api/trigger_api_test.go
Expected behavior
The variable in the playbook remains exactly the same except for the values provided by the properties in the payload-specified variables.
Additional context
As solution, we should implement a function that receiving a variable in input from a payload (not marshalled to a cacao.Variable object), marshals it in a cacao.Variable object but also taking into account the variable it will substitute the values of. This will also allow us to e.g. prevent payload-provided variables from overwriting the "external" property.
Then, we should also implement a property-by-property merge function for the cacao.Variables which accounts for initialisation-provided values, diffs between payload-provided and playbook-present variables, and prevents overwriting of meta properties e.g. bool, and const (modifying these fields should pertain to playbook editing tasks. It's surely not a within-execution task).
The text was updated successfully, but these errors were encountered: