{"record":{"id":"6a5c527231905c72","repo":"windmill-labs/windmill","slug":"trigger-kind-is-required-when-discarding-a-trigger","errorCode":null,"errorMessage":"trigger_kind is required when discarding a trigger draft.","messagePattern":"trigger_kind is required when discarding a trigger draft\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":6146,"sourceCode":"function createOpenVariableAction(path: string): ToolDisplayAction {\n\treturn {\n\t\tid: `open-deployed-variable:${path}`,\n\t\ttype: 'open_created_resource',\n\t\tlabel: 'Open variable',\n\t\tresource: 'variable',\n\t\tpath\n\t}\n}\n\nasync function discardLocalDraft(\n\targs: { type: WorkspaceItemType; path: string; trigger_kind?: TriggerKind },\n\tctx: WriteDraftCtx\n): Promise<string> {\n\tconst { workspace, toolId, toolCallbacks } = ctx\n\tconst { type, path, trigger_kind: triggerKind } = args\n\n\tif (type === 'trigger' && !triggerKind) {\n\t\tthrow new Error('trigger_kind is required when discarding a trigger draft.')\n\t}\n\n\tconst draft = await getGlobalDraft(workspace, type, path, triggerKind)\n\tif (!draft) {\n\t\tthrow new Error(`No draft found for ${type} \"${path}\".`)\n\t}\n\n\tawait deleteGlobalDraft(workspace, type, path, triggerKind)\n\n\t// The chat's touch on the item is undone — drop it from the mask so a\n\t// pre-existing deployed item doesn't keep reading as this chat's edit.\n\tconst discardedKind = itemKindFor(type, triggerKind)\n\tif (discardedKind) {\n\t\ttoolCallbacks.onItemDiscarded?.(\n\t\t\tdiscardedKind,\n\t\t\tgetGlobalDraftStoragePath(workspace, type, path, triggerKind)\n\t\t)\n\t}","sourceCodeStart":6128,"sourceCodeEnd":6164,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L6128-L6164","documentation":"The discard_draft tool requires a `trigger_kind` argument when discarding a draft of type 'trigger', because draft storage for triggers is keyed by trigger kind in addition to path. The tool throws before touching any draft when the kind is missing.","triggerScenarios":"discard_draft is called with `type: 'trigger'` but `trigger_kind` is undefined/empty — the model omitted the argument or called with only path.","commonSituations":"Model generalizing from script/flow discards (which need no kind) to triggers; schema for the tool not fully respected by the model; args constructed programmatically without the optional field.","solutions":["Re-call discard_draft including trigger_kind (e.g. 'websocket', 'schedule', 'http')","List the item's triggers to determine which trigger_kind applies","For non-trigger types, ensure type is not 'trigger' if no kind is known"],"exampleFix":"// before\ndiscard_draft({ type: 'trigger', path: 'u/admin/ingest' })\n// after\ndiscard_draft({ type: 'trigger', path: 'u/admin/ingest', trigger_kind: 'websocket' })","handlingStrategy":"validation","validationCode":"if (args.type === 'trigger' && !args.trigger_kind) {\n  throw new Error('trigger_kind is required when discarding a trigger draft.')\n}","typeGuard":"function canDiscard(args: { type: string; trigger_kind?: string }):\n  args is { type: 'trigger'; trigger_kind: string } | { type: string; trigger_kind?: string } {\n  return args.type !== 'trigger' || !!args.trigger_kind\n}","tryCatchPattern":"try {\n  await discardDraft(args)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('trigger_kind is required')) {\n    // look up the item's trigger kind and retry with it\n  }\n}","preventionTips":["Always populate trigger_kind for type 'trigger' — enumerate triggers first if unknown","Validate args against the tool's schema before dispatching","Remember trigger drafts are keyed by (type, path, trigger_kind)"],"tags":["ai-agent","missing-argument","draft-management"],"backgroundTag":"missing-required-argument","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"}