From 85926ae7849063ccd727f42422acaf04055a82fc Mon Sep 17 00:00:00 2001 From: Rohit Rajan Date: Wed, 5 Nov 2025 23:23:19 +0530 Subject: [PATCH] fix: null error --- maxun-core/src/preprocessor.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/maxun-core/src/preprocessor.ts b/maxun-core/src/preprocessor.ts index 3d4307a9..f56f9d38 100644 --- a/maxun-core/src/preprocessor.ts +++ b/maxun-core/src/preprocessor.ts @@ -55,7 +55,7 @@ export default class Preprocessor { */ static getParams(workflow: WorkflowFile): string[] { const getParamsRecurse = (object: any): string[] => { - if (typeof object === 'object') { + if (typeof object === 'object' && object !== null) { // Recursion base case if (object.$param) { return [object.$param]; @@ -141,14 +141,24 @@ export default class Preprocessor { } const out = object; - // for every key (child) of the object + Object.keys(object!).forEach((key) => { - // if the field has only one key, which is `k` - if (Object.keys((object)[key]).length === 1 && (object)[key][k]) { - // process the current special tag (init param, hydrate regex...) - (out)[key] = f((object)[key][k]); - } else { - initSpecialRecurse((object)[key], k, f); + const childValue = (object)[key]; + + if (!childValue || typeof childValue !== 'object') { + return; + } + + try { + const childKeys = Object.keys(childValue); + + if (childKeys.length === 1 && childValue[k]) { + (out)[key] = f(childValue[k]); + } else { + initSpecialRecurse(childValue, k, f); + } + } catch (error) { + console.warn(`Error processing key "${key}" in initSpecialRecurse:`, error); } }); return out;