[Security Solution] Substitute MissingVersion
symbol in the ThreeWayDiff
object with a boolean
#188277
Labels
8.16 candidate
Feature:Prebuilt Detection Rules
Security Solution Prebuilt Detection Rules area
refactoring
Team:Detection Rule Management
Security Detection Rule Management Team
Team:Detections and Resp
Security Detection Response Team
Team: SecuritySolution
Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc.
Epics: https://github.com/elastic/security-team/issues/1974 (internal), #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
.The text was updated successfully, but these errors were encountered: