Closed nikitaindik closed 1 month ago
Pinging @elastic/security-detections-response (Team:Detections and Resp)
Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management)
Pinging @elastic/security-solution (Team: SecuritySolution)
Epics: https://github.com/elastic/security-team/issues/1974 (internal), https://github.com/elastic/kibana/issues/174168
Summary
TL;DR: We can't use the
MissingVersion
symbol in UI code because it's getting cut away from backend responses.When calculating a three-way diff for a rule field, we take the value of this field from each of the three rule versions: base, current, and target. In case the base version of a rule is missing, we set the field's value to a
MissingVersion
symbol.Thus, we pass an object of this shape to a diffing algorithm function, like
simpleDiffAlgorithm
:Each diffing algorithm function returns a
ThreeWayDiff
object that is later sent to the front end.Before being sent to the FE the
ThreeWayDiff
gets converted into a JSON. And sobase_version
:MissingVersion
symbol becomesbase_version
: undefined since JS symbols don't exist in JSON.This makes using the
ThreeWayDiff
TS type unsafe on the FE because the received object can now havebase_version
equal to undefined, while the TS type "guarantees"base_version
to be either a symbol or an actual field value.One way to solve this would be to not use the
MissingVersion symbol
inThreeWayDiff
but to add a boolean property likehas_base_version
.