{"record":{"id":"8027ffff83c885da","repo":"windmill-labs/windmill","slug":"error-from-getworkspacemutationtargeterror","errorCode":null,"errorMessage":"error (from getWorkspaceMutationTargetError)","messagePattern":"error \\(from getWorkspaceMutationTargetError\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/workspaceTools.ts","lineNumber":119,"sourceCode":"\t\treturn 'the script or flow needs to be deployed before doing this action'\n\t}\n\tif (!emptyString(target.path) && target.deployed) {\n\t\treturn undefined\n\t}\n\treturn `the ${target.kind} needs to be deployed before doing this action`\n}\n\nfunction validateWorkspaceMutationTarget(helpers: unknown): string | undefined {\n\treturn getWorkspaceMutationTargetError(getWorkspaceMutationTarget(helpers))\n}\n\nfunction requireWorkspaceMutationTarget(\n\thelpers: unknown\n): WorkspaceMutationTarget & { path: string } {\n\tconst target = getWorkspaceMutationTarget(helpers)\n\tconst error = getWorkspaceMutationTargetError(target)\n\tif (error) {\n\t\tthrow new Error(error)\n\t}\n\treturn target as WorkspaceMutationTarget & { path: string }\n}\n\nfunction getWorkspaceMutationTargetFields(\n\thelpers: unknown\n): Pick<NewSchedule, 'script_path' | 'is_flow'> {\n\tconst target = requireWorkspaceMutationTarget(helpers)\n\treturn {\n\t\tscript_path: target.path,\n\t\tis_flow: target.kind === 'flow'\n\t}\n}\n\nconst createScheduleToolDef = createToolDef(\n\tcreateScheduleToolSchema,\n\t'create_schedule',\n\t'Create a schedule for the current script or flow. For anything beyond a plain cron (retry, pausing, tags, error-handler tuning), call get_schedule_schema first and pass those through `advanced`.',","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/workspaceTools.ts#L101-L137","documentation":"requireWorkspaceMutationTarget resolves the 'current script or flow' context (helpers) into a mutation target and validates it. getWorkspaceMutationTargetError returns a message when the target is missing or not deployed ('the script or flow needs to be deployed before doing this action'); when present, this Error is thrown. Tools like create_schedule/create_trigger use it as a precondition, so it fires before any API call.","triggerScenarios":"Calling create_schedule / create_trigger (or getWorkspaceMutationTargetFields) while the copilot has no script/flow open, or while the open script/flow is a draft that has never been deployed (target.deployed false or empty path).","commonSituations":"User asks the AI chat to schedule a brand-new unsaved script; the editor is on a new untitled flow; chat is opened in a context where no script/flow is active; the draft has edits so the deployed flag is stale.","solutions":["Deploy the current script or flow (Save/Deploy in the editor) before asking the copilot to create schedules or triggers","Open the script/flow in the editor so the chat has a mutation target in its helpers","Use the chat's save/deploy tooling first, then retry the schedule/trigger creation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const target = getWorkspaceMutationTarget(helpers)\nconst err = getWorkspaceMutationTargetError(target)\nif (err) return err // surface before attempting the tool call","typeGuard":null,"tryCatchPattern":"try {\n  await createScheduleTool.fn(ctx)\n} catch (e) {\n  if (/needs to be deployed/.test((e as Error).message)) {\n    await deployCurrentScriptOrFlow(); return createScheduleTool.fn(ctx)\n  }\n  throw e\n}","preventionTips":["Deploy (save) the script/flow before asking the copilot for schedules/triggers","Run validateBeforeConfirmation (the tools already do) to fail early with a clear message","Keep the editor context open on the script/flow you want to mutate"],"tags":["copilot","precondition","deployment","schedules","triggers"],"backgroundTag":"resource-not-deployed","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"}