From b9d692cf5b491ab22a40ec69e77ff7bdc62eec63 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Fri, 13 Mar 2026 20:26:28 +0100 Subject: [PATCH] fix: normalize field references and handle undefined values in JSON --- apps/api/src/services/WorkflowExecutionService.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/api/src/services/WorkflowExecutionService.ts b/apps/api/src/services/WorkflowExecutionService.ts index b0011a8..420eb1a 100644 --- a/apps/api/src/services/WorkflowExecutionService.ts +++ b/apps/api/src/services/WorkflowExecutionService.ts @@ -760,7 +760,8 @@ export class WorkflowExecutionService { field, operator, expectedValue: value, - actualValue, + // Convert undefined to null so it's preserved in JSON (JSON.stringify removes undefined) + actualValue: actualValue === undefined ? null : actualValue, result, branch: result ? 'yes' : 'no', }; @@ -996,7 +997,15 @@ export class WorkflowExecutionService { * Helper: Resolve field value from object using dot notation */ private static resolveField(field: string, data: Record): unknown { - const parts = field.split('.'); + // Handle legacy "contact.data.X" format by converting to "data.X" + // The UI historically showed examples like "contact.data.plan" but the field structure + // has "data" as a top-level key, not nested under "contact" + let normalizedField = field; + if (field.startsWith('contact.data.')) { + normalizedField = field.substring(8); // Remove "contact." prefix, leaving "data.X" + } + + const parts = normalizedField.split('.'); let value: unknown = data; for (const part of parts) {