{"record":{"id":"88095d4445b83e53","repo":"windmill-labs/windmill","slug":"invalid-fieldname-error-message-unknown","errorCode":null,"errorMessage":"Invalid ${fieldName}: ${error?.message ?? 'unknown error'}","messagePattern":"Invalid (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/flow/editableFlowJson.ts","lineNumber":316,"sourceCode":"\n\treturn parsedModules\n}\n\nexport function validateFlowSchema(rawSchema: unknown): Record<string, any> | null {\n\tif (rawSchema == null) return null\n\tif (typeof rawSchema !== 'object' || Array.isArray(rawSchema)) {\n\t\tthrow new Error('Flow schema must be an object or null')\n\t}\n\treturn rawSchema as Record<string, any>\n}\n\nfunction validateOptionalFlowModule(rawModule: unknown, fieldName: string): FlowModule | null {\n\tif (rawModule == null) return null\n\n\tconst result = flowModuleSchema.safeParse(rawModule)\n\tif (!result.success) {\n\t\tconst error = result.error.issues[0]\n\t\tthrow new Error(`Invalid ${fieldName}: ${error?.message ?? 'unknown error'}`)\n\t}\n\treturn result.data\n}\n\nexport const EDITABLE_FLOW_STRUCTURAL_KEYS = [\n\t'modules',\n\t'schema',\n\t'preprocessor_module',\n\t'failure_module',\n\t'groups',\n\t'notes'\n] as const\n\n/**\n * Parse and validate a raw object as an `EditableFlowJson`. Validates module\n * shape, schema shape, optional special modules (with their reserved ids),\n * groups, top-level flow settings, and that no module ids collide.\n */","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/flow/editableFlowJson.ts#L298-L334","documentation":"validateOptionalFlowModule parses a preprocessor_module or failure_module through the generated flowModuleSchema (zod) and throws the first zod issue's message wrapped as `Invalid <fieldName>: ...` when the module doesn't conform. This validates special optional modules in the copilot's editable flow JSON against the same schema used for regular flow modules.","triggerScenarios":"Calling flowTools modules/patches where preprocessor_module or failure_module is present but fails flowModuleSchema — e.g. missing `id`, an unknown `value.type`, a wrong-typed `value`, or missing required fields like `input_transforms`.","commonSituations":"An LLM writes a failure module without a `value.type`; a hand-edited module omits required fields; a module shape copied from an older Windmill version no longer matches the generated schema.","solutions":["Read the zod issue message after 'Invalid <fieldName>:' — it names the exact path and expected type.","Fix the module so it conforms to flowModuleSchema (correct `id`, a valid `value` with a supported `type`, required fields present).","Validate the module locally with the same zod schema before calling the tool to catch all issues at once."],"exampleFix":"// before\n{\"preprocessor_module\":{\"id\":\"prep\"}}\n// after\n{\"preprocessor_module\":{\"id\":\"prep\",\"value\":{\"type\":\"rawscript\",\"language\":\"python3\",\"content\":\"print('hi')\"}}}","handlingStrategy":"validation","validationCode":"import { flowModuleSchema } from './openFlowZod.gen'\nconst r = flowModuleSchema.safeParse(rawModule)\nif (!r.success) {\n  console.error(r.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join('; '))\n}","typeGuard":"function isFlowModule(v) {\n  return flowModuleSchema.safeParse(v).success\n}","tryCatchPattern":"try {\n  validateEditableFlowJson(flow)\n} catch (e) {\n  const m = /^(Invalid (preprocessor_module|failure_module): )(.*)$/.exec(String(e.message))\n  if (m) {\n    // m[3] is the zod issue message; fix that path and retry\n  } else throw e\n}","preventionTips":["Parse modules with the generated zod schema before submitting","Always include id and a fully-formed value with a supported type","Regenerate the zod schema after backend API changes so shapes stay current"],"tags":["validation","zod","flow-module"],"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"}