{"record":{"id":"9d3141ed7aef3900","repo":"windmill-labs/windmill","slug":"invalid-field-only-rawscript-and-script-mo","errorCode":null,"errorMessage":"Invalid ${field}: only \"rawscript\" and \"script\" modules are supported","messagePattern":"Invalid (.+?): only \"rawscript\" and \"script\" modules are supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/core.ts","lineNumber":278,"sourceCode":"\t}\n\n\tconst result = flowModuleSchema.safeParse(module)\n\tif (!result.success) {\n\t\tconst errors = result.error.issues.slice(0, 5).map((issue) => {\n\t\t\tconst path = issue.path.length > 0 ? issue.path.join('.') : field\n\t\t\treturn `${path}: ${issue.message}`\n\t\t})\n\t\tthrow new Error(`Invalid ${field}:\\n${errors.join('\\n')}`)\n\t}\n\n\tconst parsedModule = result.data\n\tconst expectedId = specialFlowModuleFields[field]\n\tif (parsedModule.id !== expectedId) {\n\t\tthrow new Error(`Invalid ${field}: id must be \"${expectedId}\"`)\n\t}\n\n\tif (parsedModule.value.type !== 'rawscript' && parsedModule.value.type !== 'script') {\n\t\tthrow new Error(`Invalid ${field}: only \"rawscript\" and \"script\" modules are supported`)\n\t}\n\n\treturn parsedModule\n}\n\nconst patchFlowJsonSchema = z.object({\n\told_string: z.string().min(1).describe('Exact text to find in the current compact flow JSON'),\n\tnew_string: z.string().describe('Replacement JSON text'),\n\treplace_all: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.default(false)\n\t\t.describe(\n\t\t\t'When true, replace every exact match. When false, the search text must match exactly once.'\n\t\t)\n})\n\nconst patchFlowJsonToolDef = createToolDef(","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/core.ts#L260-L296","documentation":"validateSpecialFlowModule finally checks parsedModule.value.type and permits only 'rawscript' or 'script'; anything else throws 'Invalid <field>: only \"rawscript\" and \"script\" modules are supported'. Special flow slots must be backed by executable script modules.","triggerScenarios":"The module passed for `field` has value.type of e.g. 'flow', 'loop', 'aiagent', 'http', 'identity', or another non-script module type.","commonSituations":"Model generated a nested flow or a non-script module for a slot that must run code; caller copied a generic flow module into a special field; attempt to wrap subflows where a script is required.","solutions":["Replace the module's value with a 'rawscript' or 'script' module (content, language, plus input schema for rawscript).","Move the non-script logic into a script module and reference external resources from the script instead.","If a subflow is genuinely needed, restructure so the special slot calls a script that triggers the flow."],"exampleFix":"// before\n\"value\": { \"type\": \"flow\", \"path\": \"f/sub\" }\n// after\n\"value\": { \"type\": \"rawscript\", \"language\": \"python\", \"content\": \"...\", \"input_transforms\": {} }","handlingStrategy":"validation","validationCode":"if (module.value.type !== 'rawscript' && module.value.type !== 'script') {\n  throw new Error('Special module must be a rawscript or script module')\n}","typeGuard":"function isScriptModuleValue(v: { type: string }): v is { type: 'rawscript' | 'script' } {\n  return v.type === 'rawscript' || v.type === 'script'\n}","tryCatchPattern":"try {\n  await tool.updateSpecialModule(field, module)\n} catch (e) {\n  if (e.message.includes('only \"rawscript\" and \"script\"')) {\n    return requestModelRetry('Convert the module to a rawscript or script module.')\n  }\n  throw e\n}","preventionTips":["Enforce module type == rawscript|script in your generation prompt/schema.","Convert non-script logic (subflows, http, etc.) into scripts before inserting into special slots.","Add a client-side type check before sending flow JSON to the tool."],"tags":["flow","validation","module-type"],"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"}