{"record":{"id":"1519c9fb5eb3e984","repo":"windmill-labs/windmill","slug":"label-is-invalid-formatzoderror-result-error","errorCode":null,"errorMessage":"${label} is invalid: ${formatZodError(result.error)}","messagePattern":"(.+?) is invalid: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/workspaceTools.ts","lineNumber":293,"sourceCode":"\t\treturn 'value'\n\t}\n\treturn path\n\t\t.map((part) => (typeof part === 'number' ? `[${part}]` : String(part)))\n\t\t.join('.')\n\t\t.replaceAll('.[', '[')\n}\n\nfunction formatZodError(error: z.ZodError): string {\n\treturn error.issues\n\t\t.slice(0, 8)\n\t\t.map((issue) => `${formatPath(issue.path)}: ${issue.message}`)\n\t\t.join('; ')\n}\n\nfunction parseWithExplicitErrors<T>(schema: z.ZodType<T>, value: unknown, label: string): T {\n\tconst result = schema.safeParse(value)\n\tif (!result.success) {\n\t\tthrow new Error(`${label} is invalid: ${formatZodError(result.error)}`)\n\t}\n\treturn result.data\n}\n\nfunction setToolError(toolCallbacks: ToolCallbacks, toolId: string, error: unknown): string {\n\tconst errorMessage = error instanceof Error ? error.message : String(error)\n\ttoolCallbacks.setToolStatus(toolId, {\n\t\tcontent: errorMessage,\n\t\terror: errorMessage,\n\t\tisLoading: false,\n\t\tneedsConfirmation: false\n\t})\n\treturn `Error while calling tool: ${errorMessage}`\n}\n\nconst createScheduleTool: Tool<any> = {\n\tdef: createScheduleToolDef,\n\trequiresConfirmation: true,","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/workspaceTools.ts#L275-L311","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncreate_trigger({ kind: 'webhook', path: '' })\n// after\ncreate_trigger({ kind: 'http', path: 'u/user/my_http_trigger', config: { ... } })","handlingStrategy":"validation","validationCode":"const check = schema.safeParse(args)\nif (!check.success) {\n  console.error('Invalid tool args:', check.error.issues)\n  return // fix args before invoking the tool\n}","typeGuard":null,"tryCatchPattern":"try {\n  const parsed = parseWithExplicitErrors(schema, args, 'Trigger')\n} catch (e) {\n  // message lists `field: message` pairs; feed back to the model/user to correct args\n  console.error((e as Error).message)\n}","preventionTips":["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)"],"tags":["zod","validation","copilot","tool-arguments"],"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"}