Once slack rule actions form is rendered:
First setActionIdByIndex in x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_field/index.tsx fires update to actions field of form (but w/o params properties, only type of selector in action).
Then, subsequently setActionParamsProperty updates params in field actions of form with values displayed if form controls through calling field.setValue. In our case, it is a message form field in slack action form.
These updates trigger form validation, defined in schema:
validateRuleActionsField receives in curried function argument field value:
const [{ value, path }] = data as [{ value: RuleAction[]; path: string }];
which doesn't have updates set in setActionParamsProperty, hence form is marked as invalid. It happens consistently when you add some action, remove it, add again it.
Here is logged form value of actions in functions calls
From the log above: validateRuleActionsField is not getting called after setActionParamsProperty is called, instead validateRuleActionsField called twice after setActionIdByIndex has been triggered.
Expected behaviour
Validation to be triggered once new params values were updated through setActionParamsProperty.
Steps to reproduce
Issue was found, once working on https://github.com/elastic/kibana/issues/140593. Rule actions form is marked as invalid, even though all fields are populated in slack action form
https://user-images.githubusercontent.com/92328789/193028904-c341e5d8-12d5-45cb-a803-aa3193852bc4.mov
Technical overview
Once slack rule actions form is rendered: First
setActionIdByIndex
in x-pack/plugins/security_solution/public/detections/components/rules/rule_actions_field/index.tsx fires update toactions
field of form (but w/o params properties, only type of selector in action). Then, subsequentlysetActionParamsProperty
updates params in field actions of form with values displayed if form controls through calling field.setValue. In our case, it is a message form field in slack action form.These updates trigger form validation, defined in schema:
validateRuleActionsField receives in curried function argument field value:
which doesn't have updates set in
setActionParamsProperty
, hence form is marked as invalid. It happens consistently when you add some action, remove it, add again it.Here is logged form value of
actions
in functions callsFrom the log above:
validateRuleActionsField
is not getting called aftersetActionParamsProperty
is called, insteadvalidateRuleActionsField
called twice aftersetActionIdByIndex
has been triggered.Expected behaviour
Validation to be triggered once new params values were updated through
setActionParamsProperty
.Workaround
field.setValue
in setTimeout helped to resolve the issue. Implemented in https://github.com/elastic/kibana/pull/141811/files for 8.5+, but root cause hasn't been found