From 8f65f8ecd53352ce5ad4f75390af7736d9467a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obermu=CC=88ller?= Date: Thu, 27 Nov 2025 17:20:08 +0100 Subject: [PATCH 1/2] fix(cdp): fix filter overrides for hog functions --- .../list/hogFunctionTemplateListLogic.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx index b57c66ca82a55..87d45e213c863 100644 --- a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx +++ b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.tsx @@ -250,9 +250,17 @@ export const hogFunctionTemplateListLogic = kea = { ...subTemplate, - ...configurationOverrides, + ...(filters ? { filters } : {}), } return combineUrl( From 1a1a4b896f86f0ff9ca7480be1db9edd81a6db2c Mon Sep 17 00:00:00 2001 From: meikel Date: Fri, 28 Nov 2025 16:05:41 +0100 Subject: [PATCH 2/2] add test --- .../list/hogFunctionTemplateListLogic.test.ts | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts diff --git a/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts new file mode 100644 index 0000000000000..82f67a18278ab --- /dev/null +++ b/frontend/src/scenes/hog-functions/list/hogFunctionTemplateListLogic.test.ts @@ -0,0 +1,60 @@ +import { initKeaTests } from '~/test/init' +import { + CyclotronJobFiltersType, + HogFunctionTemplateWithSubTemplateType, + PropertyFilterType, + PropertyOperator, +} from '~/types' + +import { hogFunctionTemplateListLogic } from './hogFunctionTemplateListLogic' + +describe('hogFunctionTemplateListLogic - configuration structure', () => { + beforeEach(() => { + initKeaTests() + }) + + it('should wrap filters in configuration object, not spread at top level', () => { + const alertId = 'test-alert-id-123' + const getConfigurationOverrides = (): CyclotronJobFiltersType => ({ + properties: [ + { + key: 'alert_id', + value: alertId, + operator: PropertyOperator.Exact, + type: PropertyFilterType.Event, + }, + ], + events: [{ id: '$insight_alert_firing', type: 'events' as const }], + }) + + const logic = hogFunctionTemplateListLogic.build({ + type: 'destination', + getConfigurationOverrides, + }) + logic.mount() + + const template: HogFunctionTemplateWithSubTemplateType = { + id: 'template-slack', + name: 'Slack', + type: 'destination', + status: 'stable', + free: true, + code: 'return event', + code_language: 'hog', + sub_template_id: 'insight-alert-firing', + } + + const url = logic.values.urlForTemplate(template) + expect(url).toBeTruthy() + + // Parse URL to verify structure + const urlObj = new URL(url!, window.location.origin) + const hashParams = new URLSearchParams(urlObj.hash.substring(1)) + const configuration = JSON.parse(decodeURIComponent(hashParams.get('configuration') || '{}')) + + // filters must be wrapped, not at top level + expect(configuration).toHaveProperty('filters') + expect(configuration.filters).toHaveProperty('properties') + expect(configuration).not.toHaveProperty('properties') // Should not be at top level + }) +})