{"record":{"id":"4e626a11ab30dd40","repo":"windmill-labs/windmill","slug":"invalid-preprocessor-module-only-rawscript-and","errorCode":null,"errorMessage":"Invalid preprocessor_module: only \"rawscript\" and \"script\" modules are supported","messagePattern":"Invalid preprocessor_module: only \"rawscript\" and \"script\" modules are supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/editableFlowJson.ts","lineNumber":387,"sourceCode":"\t\tflow.preprocessor_module,\n\t\t'preprocessor_module'\n\t)\n\tconst failureModule = validateOptionalFlowModule(flow.failure_module, 'failure_module')\n\tconst groupModuleIds = new Set(collectAllFlowModuleIdsFromModules(modules))\n\tconst groups = validateFlowGroups(flow.groups, groupModuleIds)\n\tconst notes = validateFlowNotes(flow.notes, groupModuleIds)\n\n\tif (preprocessorModule) {\n\t\tif (preprocessorModule.id !== SPECIAL_MODULE_IDS.PREPROCESSOR) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid preprocessor_module: id must be \"${SPECIAL_MODULE_IDS.PREPROCESSOR}\"`\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tpreprocessorModule.value.type !== 'rawscript' &&\n\t\t\tpreprocessorModule.value.type !== 'script'\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t'Invalid preprocessor_module: only \"rawscript\" and \"script\" modules are supported'\n\t\t\t)\n\t\t}\n\t}\n\tif (failureModule) {\n\t\tif (failureModule.id !== SPECIAL_MODULE_IDS.FAILURE) {\n\t\t\tthrow new Error(`Invalid failure_module: id must be \"${SPECIAL_MODULE_IDS.FAILURE}\"`)\n\t\t}\n\t\tif (failureModule.value.type !== 'rawscript' && failureModule.value.type !== 'script') {\n\t\t\tthrow new Error('Invalid failure_module: only \"rawscript\" and \"script\" modules are supported')\n\t\t}\n\t}\n\n\tconst ids = new Set(collectAllFlowModuleIdsFromModules(modules))\n\tif (preprocessorModule) {\n\t\tif (ids.has(preprocessorModule.id)) {\n\t\t\tthrow new Error(`Duplicate module ID found in preprocessor_module: ${preprocessorModule.id}`)\n\t\t}","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/editableFlowJson.ts#L369-L405","documentation":"A preprocessor_module must have a value of type \"rawscript\" or \"script\"; the preprocessor runs inline code before the flow body, so other module types (aiagent, flow, scriptloader, etc.) are invalid there. This complements the id check with a type check on the module's value.","triggerScenarios":"Calling flowTools modules/patches with preprocessor_module set to a module whose value.type is e.g. \"aiagent\", \"flow\", or \"identity\" while the id is correct.","commonSituations":"An LLM wires an AI agent or subflow as a preprocessor; a regular module is pasted into preprocessor_module without changing its type; template misuse.","solutions":["Replace the preprocessor_module value with a rawscript or script value (type, content/code, language set).","Move non-script module types into the regular modules list instead.","Re-run the tool after converting the module."],"exampleFix":"// before\n{\"preprocessor_module\":{\"id\":\"preprocessor\",\"value\":{\"type\":\"aiagent\",...}}}\n// after\n{\"preprocessor_module\":{\"id\":\"preprocessor\",\"value\":{\"type\":\"rawscript\",\"language\":\"python3\",\"content\":\"...\"}}}","handlingStrategy":"validation","validationCode":"const t = flow.preprocessor_module?.value?.type\nif (t && t !== 'rawscript' && t !== 'script')\n  throw new Error(`preprocessor_module type must be rawscript|script, got ${t}`)","typeGuard":"function isScriptValue(v) {\n  return v?.type === 'rawscript' || v?.type === 'script'\n}","tryCatchPattern":"try {\n  validateEditableFlowJson(raw)\n} catch (e) {\n  if (String(e.message).includes('preprocessor_module: only')) {\n    // replace the value with a rawscript/script module or move it to modules\n  } else throw e\n}","preventionTips":["Reserve preprocessor_module for rawscript/script code only","Place agents, subflows and other module types in the regular modules list","Check value.type before assigning any module to the preprocessor slot"],"tags":["validation","flow-module","type-check"],"backgroundTag":"schema-validation-failed","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"}