diff --git a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts index 065c07c63a15b..20d65dd484055 100644 --- a/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts +++ b/frontend/src/queries/nodes/InsightQuery/utils/filtersToQueryNode.ts @@ -37,6 +37,7 @@ import { PropertyFilterType, PropertyGroupFilterValue, PropertyOperator, + RetentionEntity, } from '~/types' const reverseInsightMap: Record, InsightNodeKind> = { @@ -104,6 +105,18 @@ export const cleanHiddenLegendSeries = ( .map(([k]) => k) : undefined } +export const sanitizeRetentionEntity = (entity: RetentionEntity | undefined): RetentionEntity | undefined => { + if (!entity) { + return undefined + } + const record = { ...entity } + for (const key of Object.keys(record)) { + if (!['id', 'kind', 'name', 'type', 'order', 'uuid', 'custom_name'].includes(key)) { + delete record[key] + } + } + return record +} const cleanProperties = (parentProperties: FilterType['properties']): InsightsQueryBase['properties'] => { if (!parentProperties || !parentProperties.values) { @@ -307,8 +320,8 @@ export const filtersToQueryNode = (filters: Partial): InsightQueryNo retentionType: filters.retention_type, retentionReference: filters.retention_reference, totalIntervals: filters.total_intervals, - returningEntity: filters.returning_entity, - targetEntity: filters.target_entity, + returningEntity: sanitizeRetentionEntity(filters.returning_entity), + targetEntity: sanitizeRetentionEntity(filters.target_entity), period: filters.period, }) // TODO: query.aggregation_group_type_index