{"record":{"id":"829dcca3f6bee4e0","repo":"windmill-labs/windmill","slug":"invalid-field-n-errors-join-n","errorCode":null,"errorMessage":"Invalid ${field}:\\n${errors.join('\\n')}","messagePattern":"Invalid (.+?):\\\\n(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/core.ts","lineNumber":268,"sourceCode":"\t\tthrow new Error(`Invalid JSON for ${field}: ${errorMessage}`)\n\t}\n}\n\nfunction validateSpecialFlowModule(\n\tmodule: unknown,\n\tfield: SpecialFlowModuleField\n): FlowModule | null | undefined {\n\tif (module === undefined || module === null) {\n\t\treturn module\n\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'),","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/core.ts#L250-L286","documentation":"validateSpecialFlowModule runs flowModuleSchema.safeParse on a special flow module and throws an Error listing up to 5 Zod issues (path: message) when the module shape is invalid. Used to validate designated flow modules (e.g. approval/loop sub-fields) supplied via parsedModule or flowTools.","triggerScenarios":"The module passed for `field` fails flowModuleSchema: missing required keys (id/value), wrong value.type, invalid input/output schema, or extra unknown fields, producing result.success === false.","commonSituations":"Model-generated flow JSON omits `value` or uses a wrong module type; hand-written JSON has a typo'd property; schema drift after a Windmill version change added required fields.","solutions":["Fix each listed path in the error (up to 5 issues shown) to satisfy flowModuleSchema.","Compare against a known-good module of the same special type and copy its shape.","Validate the whole flow JSON with the flow schema first, then extract the special module."],"exampleFix":"// before\n{ \"id\": \"approval\", \"summary\": \"ok\" }\n// after\n{ \"id\": \"approval\", \"value\": { \"type\": \"rawscript\", \"content\": \"...\", \"language\": \"python\" } }","handlingStrategy":"validation","validationCode":"const check = flowModuleSchema.safeParse(module)\nif (!check.success) {\n  console.error(check.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`))\n  return\n}","typeGuard":"function isFlowModule(m: unknown): m is FlowModule {\n  return flowModuleSchema.safeParse(m).success\n}","tryCatchPattern":"try {\n  await tool.updateSpecialModule(field, module)\n} catch (e) {\n  if (String(e.message).startsWith(`Invalid ${field}`)) {\n    return requestModelRetry(e.message)\n  }\n  throw e\n}","preventionTips":["Run flowModuleSchema.safeParse on model output before submitting it.","Copy the shape from an existing valid special module rather than free-handing JSON.","Keep flow JSON generation prompts in sync with the current schema version."],"tags":["zod","schema-validation","flow","validation"],"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"}