windmill-labs/windmill · error

Invalid ${fieldName}: ${error?.message ?? 'unknown error'}

Error message

Invalid ${fieldName}: ${error?.message ?? 'unknown error'}

What it means

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.

Source

Thrown at frontend/src/lib/components/copilot/chat/flow/editableFlowJson.ts:316

	return parsedModules
}

export function validateFlowSchema(rawSchema: unknown): Record<string, any> | null {
	if (rawSchema == null) return null
	if (typeof rawSchema !== 'object' || Array.isArray(rawSchema)) {
		throw new Error('Flow schema must be an object or null')
	}
	return rawSchema as Record<string, any>
}

function validateOptionalFlowModule(rawModule: unknown, fieldName: string): FlowModule | null {
	if (rawModule == null) return null

	const result = flowModuleSchema.safeParse(rawModule)
	if (!result.success) {
		const error = result.error.issues[0]
		throw new Error(`Invalid ${fieldName}: ${error?.message ?? 'unknown error'}`)
	}
	return result.data
}

export const EDITABLE_FLOW_STRUCTURAL_KEYS = [
	'modules',
	'schema',
	'preprocessor_module',
	'failure_module',
	'groups',
	'notes'
] as const

/**
 * Parse and validate a raw object as an `EditableFlowJson`. Validates module
 * shape, schema shape, optional special modules (with their reserved ids),
 * groups, top-level flow settings, and that no module ids collide.
 */

View on GitHub (pinned to e474e8803c)

Solutions

  1. Read the zod issue message after 'Invalid <fieldName>:' — it names the exact path and expected type.
  2. Fix the module so it conforms to flowModuleSchema (correct `id`, a valid `value` with a supported `type`, required fields present).
  3. Validate the module locally with the same zod schema before calling the tool to catch all issues at once.

Example fix

// before
{"preprocessor_module":{"id":"prep"}}
// after
{"preprocessor_module":{"id":"prep","value":{"type":"rawscript","language":"python3","content":"print('hi')"}}}
Defensive patterns

Strategy: validation

Validate before calling

import { flowModuleSchema } from './openFlowZod.gen'
const r = flowModuleSchema.safeParse(rawModule)
if (!r.success) {
  console.error(r.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join('; '))
}

Type guard

function isFlowModule(v) {
  return flowModuleSchema.safeParse(v).success
}

Try / catch

try {
  validateEditableFlowJson(flow)
} catch (e) {
  const m = /^(Invalid (preprocessor_module|failure_module): )(.*)$/.exec(String(e.message))
  if (m) {
    // m[3] is the zod issue message; fix that path and retry
  } else throw e
}

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/88095d4445b83e53. Report an issue: GitHub.