windmill-labs/windmill · error
${label} is invalid: ${formatZodError(result.error)}
Error message
${label} is invalid: ${formatZodError(result.error)} What it means
parseWithExplicitErrors is the copilot tool layer's zod gate: it safeParses tool arguments against a schema and, on failure, throws an Error whose message lists up to 8 zod issues formatted as `path: message`. It turns opaque zod failures into explicit, model-readable errors for tools like get_trigger_schema, create_schedule and create_trigger.
Source
Thrown at frontend/src/lib/components/copilot/chat/workspaceTools.ts:293
return 'value'
}
return path
.map((part) => (typeof part === 'number' ? `[${part}]` : String(part)))
.join('.')
.replaceAll('.[', '[')
}
function formatZodError(error: z.ZodError): string {
return error.issues
.slice(0, 8)
.map((issue) => `${formatPath(issue.path)}: ${issue.message}`)
.join('; ')
}
function parseWithExplicitErrors<T>(schema: z.ZodType<T>, value: unknown, label: string): T {
const result = schema.safeParse(value)
if (!result.success) {
throw new Error(`${label} is invalid: ${formatZodError(result.error)}`)
}
return result.data
}
function setToolError(toolCallbacks: ToolCallbacks, toolId: string, error: unknown): string {
const errorMessage = error instanceof Error ? error.message : String(error)
toolCallbacks.setToolStatus(toolId, {
content: errorMessage,
error: errorMessage,
isLoading: false,
needsConfirmation: false
})
return `Error while calling tool: ${errorMessage}`
}
const createScheduleTool: Tool<any> = {
def: createScheduleToolDef,
requiresConfirmation: true,View on GitHub (pinned to e474e8803c)
Solutions
- Read the issues in the message (`field: message`) and fix the offending argument names/values
- For triggers, call get_trigger_schema first and pass config fields exactly as listed
- For schedules, use get_schedule_schema for advanced options (retry, pausing, tags) and pass them via `advanced`
- Ensure the target script/flow path is a non-empty string before calling
Example fix
// before
create_trigger({ kind: 'webhook', path: '' })
// after
create_trigger({ kind: 'http', path: 'u/user/my_http_trigger', config: { ... } }) Defensive patterns
Strategy: validation
Validate before calling
const check = schema.safeParse(args)
if (!check.success) {
console.error('Invalid tool args:', check.error.issues)
return // fix args before invoking the tool
} Try / catch
try {
const parsed = parseWithExplicitErrors(schema, args, 'Trigger')
} catch (e) {
// message lists `field: message` pairs; feed back to the model/user to correct args
console.error((e as Error).message)
} Prevention
- Instruct the model to fetch the schema tool (get_trigger_schema / get_schedule_schema) first
- Validate args in the UI before confirming the tool call
- Keep per-kind config fields exactly matching the published schema
- Never invent enum values (trigger kinds, cron versions)
When it happens
Trigger: Any copilot tool call whose `args` fail the tool's zod schema: missing required fields (e.g. path), wrong enum for trigger `kind`, malformed `schedule` cron, config fields not in the per-kind trigger schema — whether from the model's own output or a programmatic caller.
Common situations: LLM hallucinates a trigger kind not in the enum; model omits `path` or `local_part`; advanced option passed under the wrong key so it fails type/shape; extra unknown keys rejected by a strict 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
- Invalid JSON for ${field}: ${errorMessage}
- Invalid ${field}:\n${errors.join('\n')}
- Flow modules must be an array
- Invalid flow modules:\n${errors.join('\n')}
- Invalid ${fieldName}: ${error?.message ?? 'unknown error'}
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/1519c9fb5eb3e984.
Report an issue: GitHub.