{"record":{"id":"81b3038258d69c2f","repo":"windmill-labs/windmill","slug":"you-can-only-delete-forked-workspaces-where-the-wo","errorCode":null,"errorMessage":"You can only delete forked workspaces where the workspace id starts with \\`${WM_FORK_PREFIX}. Failed while attempting to delete \\`${workspace.workspaceId}\\`","messagePattern":"You can only delete forked workspaces where the workspace id starts with \\\\`(.+?)\\. Failed while attempting to delete \\\\`(.+?)\\\\`","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/workspace/fork.ts","lineNumber":557,"sourceCode":"async function deleteWorkspaceFork(\n  opts: GlobalOptions & {\n    yes?: boolean;\n  },\n  name: string,\n) {\n  let forkWorkspaceId: string;\n  let token: string;\n  let remote: string;\n  let hasLocalProfile = false;\n\n  // Try local profile first (existing behavior)\n  const orgWorkspaces = await allWorkspaces(opts.configDir);\n  const idxOf = orgWorkspaces.findIndex((x) => x.name === name);\n\n  if (idxOf !== -1) {\n    const workspace = orgWorkspaces[idxOf];\n    if (!workspace.workspaceId.startsWith(WM_FORK_PREFIX)) {\n      throw new Error(\n        `You can only delete forked workspaces where the workspace id starts with \\`${WM_FORK_PREFIX}.\\` Failed while attempting to delete \\`${workspace.workspaceId}\\``,\n      );\n    }\n    forkWorkspaceId = workspace.workspaceId;\n    token = workspace.token;\n    remote = workspace.remote;\n    hasLocalProfile = true;\n  } else {\n    // Fallback: resolve parent workspace from branch config and construct fork ID\n    const parentWorkspace = await tryResolveBranchWorkspace(opts);\n    if (!parentWorkspace) {\n      throw new Error(\n        \"Could not resolve parent workspace. Make sure you are in a git repo with 'workspaces' configured in wmill.yaml, or create a local workspace profile for the fork.\",\n      );\n    }\n    forkWorkspaceId = name.startsWith(`${WM_FORK_PREFIX}-`) ? name : `${WM_FORK_PREFIX}-${name}`;\n    token = parentWorkspace.token;\n    remote = parentWorkspace.remote;","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/workspace/fork.ts#L539-L575","documentation":"`wmill workspace fork delete` only deletes forked workspaces. `deleteWorkspaceFork` looks up the workspace profile by name and verifies its workspace id starts with the fork prefix (`wm-fork`); otherwise it throws rather than deleting a non-fork workspace by mistake.","triggerScenarios":"Running `wmill workspace fork delete <name>` where the resolved workspace's id does not start with `wm-fork` (e.g. it is the production/parent workspace).","commonSituations":"Passing the parent workspace name instead of the fork name; a fork that was created without the prefix (manually renamed id); typo in the fork name resolving to a normal workspace.","solutions":["Pass the fork's name/id (a workspace whose id starts with `wm-fork`)","Run `wmill workspace list` to confirm the correct fork workspace name","If you really want to remove a non-fork workspace, use the regular workspace remove command, not fork delete"],"exampleFix":"// before\nwmill workspace fork delete prod   # id: prod\n// after\nwmill workspace fork delete my-feature   # id: wm-fork-my-feature","handlingStrategy":"type-guard","validationCode":"const ws = (await allWorkspaces(opts.configDir)).find(w => w.name === name);\nif (ws && !ws.workspaceId.startsWith('wm-fork')) {\n  throw new Error(`${ws.workspaceId} is not a fork`);\n}","typeGuard":"function isForkWorkspace(w: { workspaceId: string }): boolean {\n  return w.workspaceId.startsWith(WM_FORK_PREFIX);\n}","tryCatchPattern":"try {\n  await deleteWorkspaceFork(name, opts);\n} catch (e) {\n  if (e.message.includes('only delete forked workspaces')) {\n    log.error('Target is not a fork; use regular workspace removal.');\n  } else throw e;\n}","preventionTips":["Only call fork delete with names resolved from fork listings","Check the workspace id prefix before deleting","Distinguish fork vs plain workspace removal commands"],"tags":["cli","workspace-fork","delete","guard"],"backgroundTag":"non-fork-workspace-delete","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}