{"record":{"id":"255412131a250c47","repo":"windmill-labs/windmill","slug":"failed-to-create-folder-name-e-body-e-mes","errorCode":null,"errorMessage":"Failed to create folder ${name}: ${e.body ?? e.message}","messagePattern":"Failed to create folder (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/folder/folder.ts","lineNumber":148,"sourceCode":"      });\n    } catch (e) {\n      //@ts-ignore\n      console.error(e.body);\n      throw e;\n    }\n  } else {\n    console.log(colors.bold.yellow(\"Creating new folder: \" + name));\n    try {\n      await wmill.createFolder({\n        workspace: workspace,\n        requestBody: {\n          name: name,\n          ...localFolder,\n        },\n      });\n    } catch (e) {\n      //@ts-ignore\n      throw Error(`Failed to create folder ${name}: ${e.body ?? e.message}`);\n    }\n  }\n}\n\nasync function push(opts: GlobalOptions, name: string) {\n  const workspace = await resolveWorkspace(opts);\n  await requireLogin(opts);\n\n  const metaPath = `f${SEP}${name}${SEP}folder.meta.yaml`;\n  try {\n    await stat(metaPath);\n  } catch {\n    throw new Error(`Could not find ${metaPath}. Does the folder exist locally?`);\n  }\n\n  console.log(colors.bold.yellow(\"Pushing folder...\"));\n\n  await pushFolder(","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/folder/folder.ts#L130-L166","documentation":"Raised by pushFolder in the wmill CLI when creating a folder via the Windmill API fails. The CLI catches the API error and rethrows it with the folder name and the API error body or message attached, indicating the folder could not be created on the server during `wmill folder push`.","triggerScenarios":"Calling `wmill folder push <name>` where the folder does not exist remotely, and the create-folder API call (wmill.createFolder) throws — e.g. HTTP 401/403 (bad token, insufficient permissions), 422 validation, or network errors. The catch block wraps any exception into this message.","commonSituations":"Expired or wrong-workspace API token; user lacking workspace admin rights to create folders; folder name violating naming rules; offline/VPN connectivity issues; pointing at the wrong instance URL.","solutions":["Read the appended e.body/e.message for the underlying HTTP status and fix that cause (auth, permission, validation).","Re-authenticate: run `wmill auth login` or refresh the workspace token (`wmill workspace add` with a fresh token).","Verify you can create folders in the UI — if not, request workspace admin/folder-create permissions.","Check connectivity to the instance (`curl <instance_url>/api/...`) and confirm the workspace name is correct."],"exampleFix":"// before\nthrow Error(`Failed to create folder ${name}: ${e.body ?? e.message}`);\n\n// user-side: authenticate first\n// $ wmill auth login --token <TOKEN> --workspace main\n// $ wmill folder push my_folder","handlingStrategy":"try-catch","validationCode":"// check auth and the folder name before pushing\nif (!name || name.includes(' ')) throw new Error('invalid folder name');\n// ensure `wmill workspace current` resolves and a valid token is set","typeGuard":null,"tryCatchPattern":"try {\n  await wmill.folder.push(name);\n} catch (e) {\n  if (/Failed to create folder/.test(e.message)) {\n    const detail = e.message.split(':').slice(1).join(':');\n    if (/401|403/.test(detail)) await reauth();\n    else if (/409|exists/i.test(detail)) /* folder already exists — skip */ return;\n    throw e;\n  }\n}","preventionTips":["Refresh tokens with `wmill auth login` before bulk pushes.","Verify folder-create permission in the workspace before automation.","Check whether the folder already exists to make pushes idempotent.","Validate folder names against Windmill naming rules."],"tags":["cli","api","folder","push","auth"],"backgroundTag":"api-request-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"}