{"record":{"id":"e02510b5c57a317e","repo":"windmill-labs/windmill","slug":"preprocessor-function-is-missing-e02510","errorCode":null,"errorMessage":"preprocessor function is missing","messagePattern":"preprocessor function is missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/src/deno_executor.rs","lineNumber":316,"sourceCode":"                } else {\n                    None\n                }\n            })\n            .map(|x| {\n                return format!(r#\"args[\"{x}\"] = args[\"{x}\"] ? new Date(args[\"{x}\"]) : undefined\"#);\n            })\n            .join(\"\\n    \");\n\n        let spread = args.into_iter().map(|x| x.name).join(\",\");\n        let main_name = main_override.unwrap_or(\"main\");\n        // logs.push_str(format!(\"infer args: {:?}\\n\", start.elapsed().as_micros()).as_str());\n        let (preprocessor_import, preprocessor) = if let Some(pre_args) = pre_args {\n            let pre_spread = pre_args.into_iter().map(|x| x.name).join(\",\");\n            (\n                r#\"import { preprocessor } from \"./main.ts\";\"#.to_string(),\n                format!(\n                    r#\"if (preprocessor === undefined || typeof preprocessor !== 'function') {{\n        throw new Error(\"preprocessor function is missing\");\n    }}\n    function preArgsObjToArr({{ {pre_spread} }}) {{\n        return [ {pre_spread} ];\n    }}\n    args = await preprocessor(...preArgsObjToArr(args));\n    const args_json = JSON.stringify(args ?? null, (key, value) => typeof value === 'undefined' ? null : value);\n    await Deno.writeTextFile(\"args.json\", args_json);\"#\n                ),\n            )\n        } else {\n            (\"\".to_string(), \"\".to_string())\n        };\n\n        let wrapper_content: String = format!(\n            r#\"\nimport {{ {main_name} }} from \"./main.ts\";\n{preprocessor_import}\n","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/src/deno_executor.rs#L298-L334","documentation":"This error is thrown from the generated Deno wrapper script when a workspace has a preprocessor function configured (e.g. via the 'preprocessor' extra import/entrypoint in main.ts) but the deployed module does not actually export a callable `preprocessor`. The worker synthesizes a script that imports { preprocessor } from \"./main.ts\" and checks `typeof preprocessor !== 'function'` before calling it, so a missing/renamed/non-function export aborts the job before the main function ever runs.","triggerScenarios":"Running a Deno/Bun/TypeScript script or flow step whose workspace or script settings define preprocessor args (pre_args), while the script's entry module fails to export `preprocessor` — e.g. export was deleted, renamed, or exported as a non-function value.","commonSituations":"A preprocessor was configured in workspace settings (Settings > Workspace > Preprocessor) but the user's script is a fresh template that doesn't define one; a Windmill version upgrade or template change renamed the export; someone wrote `export const preprocessor = someUndefinedValue` or exported it from a different module than the entrypoint main.ts.","solutions":["Add `export async function preprocessor(args) { ... return transformedArgs; }` to the script's entry file (the module imported as ./main.ts)","If the script needs no input transformation, remove the preprocessor configuration (pre_args) from the workspace/script settings so the wrapper stops importing it","Check the export is spelled exactly `preprocessor` and is a function (not a const object or undefined)","Verify the deployed script actually saved — an unsaved editor buffer or stale deployed version may lack the export"],"exampleFix":"// before\nexport const preprocessor; // undefined — not a function\n// after\nexport async function preprocessor(...args: any[]): Promise<any[]> {\n  const [a, b] = args;\n  return [a, b];\n}","handlingStrategy":"validation","validationCode":"// in the script entry file, before relying on it:\nif (typeof preprocessor !== 'function') {\n  throw new Error('main.ts must export a `preprocessor` function when preprocessor args are configured');\n}","typeGuard":"function isPreprocessorFn(v: unknown): v is (...args: unknown[]) => Promise<unknown[]> | unknown[] {\n  return typeof v === 'function';\n}","tryCatchPattern":null,"preventionTips":["Start every Deno script from a template that includes the preprocessor export when workspace preprocessor args are enabled","Keep preprocessor config and script exports in lockstep: remove pre_args when a script doesn't need them","Lint scripts for `export function/const preprocessor` in CI when the workspace has preprocessor enabled"],"tags":["deno","preprocessor","missing-export","worker"],"backgroundTag":"missing-preprocessor-export","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}