{"record":{"id":"fdc3d2302910a41d","repo":"windmill-labs/windmill","slug":"file-already-exists-filepath","errorCode":null,"errorMessage":"File already exists: ${filePath}","messagePattern":"File already exists: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/folder/folder.ts","lineNumber":58,"sourceCode":"      .padding(2)\n      .border(true)\n      .body(\n        folders.map((x) => [\n          x.name,\n          x.owners?.join(\",\") ?? \"-\",\n          JSON.stringify(x.extra_perms ?? {}),\n        ])\n      )\n      .render();\n  }\n}\n\nasync function newFolder(opts: GlobalOptions & { summary?: string }, name: string) {\n  const dirPath = `f${SEP}${name}`;\n  const filePath = `${dirPath}${SEP}folder.meta.yaml`;\n  try {\n    await stat(filePath);\n    throw new Error(\"File already exists: \" + filePath);\n  } catch (e: any) {\n    if (e.message?.startsWith(\"File already exists\")) throw e;\n  }\n  const template: FolderFile = {\n    summary: opts.summary ?? \"\",\n    display_name: name,\n    owners: [],\n    extra_perms: {},\n  };\n  await mkdir(dirPath, { recursive: true });\n  await writeFile(filePath, yamlStringify(template as Record<string, any>), {\n    flag: \"wx\",\n    encoding: \"utf-8\",\n  });\n  log.info(colors.green(`Created ${filePath}`));\n}\n\nasync function get(opts: GlobalOptions & { json?: boolean }, name: string) {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/folder/folder.ts#L40-L76","documentation":"Exists-check turned error in the folder command's scaffolder: stat() on f/{name}/folder.meta.yaml succeeded, meaning a local folder metadata file already occupies the name you asked newFolder to create. The input at fault is the requested folder name; the CLI refuses to overwrite an existing folder.meta.yaml. (The odd try/catch re-throw of its own error exists so the stat ENOENT path falls through to creation.)","triggerScenarios":"Thrown at cli/src/commands/folder/folder.ts:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pick a different folder name for the new folder","Edit the existing f/{name}/folder.meta.yaml directly if you meant to modify the folder","Delete the existing local folder (and its server-side counterpart if intended) before recreating it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}