:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(workflows): resolve the record alias in liquid fields (#103741)
Luke Beltona815288cef98
diff --git a/frontend/src/lib/components/CyclotronJob/DataWarehouseColumnsHint.tsx b/frontend/src/lib/components/CyclotronJob/DataWarehouseColumnsHint.tsxindex b60196fcf3ac..7a201ece2a1f 100644--- a/frontend/src/lib/components/CyclotronJob/DataWarehouseColumnsHint.tsx+++ b/frontend/src/lib/components/CyclotronJob/DataWarehouseColumnsHint.tsx@@ -15,8 +15,10 @@ export type DataWarehouseColumnsHintProps = {/*** Shows the columns of the selected warehouse table and how to reference them in templates.- * Warehouse rows are delivered under `event.properties`, but `{record.<column>}` is the friendlier- * alias users write (rewritten on save) — so we surface that form with click-to-copy.+ * Warehouse rows are delivered under `event.properties`, but `record` is the friendlier alias users+ * write, so we surface that form with click-to-copy. A hog field has the alias rewritten on save; a+ * liquid field resolves it at render. The engine is chosen per field on each downstream step, which+ * this panel cannot see, so the text names both forms rather than guessing one.*/export function DataWarehouseColumnsHint({schemaColumns,@@ -37,14 +39,15 @@ export function DataWarehouseColumnsHint({content: (<div className="flex flex-col gap-2"><p className="mb-0 text-xs text-secondary">- Use <code>{'{record.<column>}'}</code> in your templates to insert a value from the+ Use <code>{'{record.<column>}'}</code> in Hog fields or{' '}+ <code>{'{{ record.<column> }}'}</code> in Liquid fields to insert a value from thesynced row.{' '}{personAvailable ? (<>- <code>{'{person}'}</code> and <code>{'{event}'}</code> are also available.{' '}+ <code>person</code> and <code>event</code> work the same way.{' '}</>) : null}- Click a column to copy its reference.+ Click a column to copy the Hog form.</p><div className="flex flex-wrap gap-1">{schemaColumns.map((column) => (diff --git a/nodejs/src/cdp/utils/liquid.test.ts b/nodejs/src/cdp/utils/liquid.test.tsindex ba756eb5efd7..4c846b03795a 100644--- a/nodejs/src/cdp/utils/liquid.test.ts+++ b/nodejs/src/cdp/utils/liquid.test.ts@@ -60,6 +60,19 @@ describe('LiquidRenderer', () => {})})+ describe('warehouse row record alias', () => {+ it.each([+ ['$warehouse_view_row', '[email protected]'],+ ['$warehouse_source_row', '[email protected]'],+ ['test_event', ''],+ ])('renders {{ record.email }} for %s as "%s"', (eventName, expected) => {+ globals.event.event = eventName+ globals.event.properties = { email: '[email protected]' }++ expect(LiquidRenderer.renderWithHogFunctionGlobals('{{ record.email }}', globals)).toBe(expected)+ })+ })+describe('memoized initialisation', () => {it('only initialises once', () => {LiquidRenderer['_liquid'] = nulldiff --git a/nodejs/src/cdp/utils/liquid.ts b/nodejs/src/cdp/utils/liquid.tsindex 426b83c418b2..abd677b2d658 100644--- a/nodejs/src/cdp/utils/liquid.ts+++ b/nodejs/src/cdp/utils/liquid.ts@@ -1,5 +1,6 @@import { Liquid } from 'liquidjs'+import { rowScopedTriggerTypeForEvent } from '../schema/hogflow'import { HogFunctionInvocationGlobalsWithInputs } from '../types'// Rendering is synchronous on shared multi-tenant workers, so an unbounded template would@@ -116,9 +117,15 @@ export class LiquidRenderer {throw new Error(`liquid parse length limit exceeded (${LIQUID_PARSE_LIMIT_CHARS} characters)`)}+ // A warehouse row arrives under `event.properties`, and `record` is the alias the trigger+ // panel tells people to write. A hog-templated input gets that alias rewritten at save time,+ // but a liquid-templated input renders here, so the alias has to exist in the context.+ const isWarehouseRow = rowScopedTriggerTypeForEvent(globals.event?.event) !== null+const context = {...globals,now: new Date(),+ ...(isWarehouseRow ? { record: globals.event?.properties ?? {} } : {}),}const start = performance.now()