{"record":{"id":"b3c40370c7b0c37e","repo":"windmill-labs/windmill","slug":"file-already-exists-filepath-b3c403","errorCode":null,"errorMessage":"File already exists: + filePath","messagePattern":"File already exists: \\+ filePath","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/resource-type/resource-type.ts","lineNumber":134,"sourceCode":"          JSON.stringify(x.schema, null, 2),\n        ])\n      )\n      .render();\n  } else {\n    new Table()\n      .header([\"Workspace\", \"Name\"])\n      .padding(2)\n      .border(true)\n      .body(res.map((x) => [x.workspace_id ?? \"Global\", x.name]))\n      .render();\n  }\n}\n\nasync function newResourceType(opts: GlobalOptions, name: string) {\n  const filePath = name + \".resource-type.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: ResourceTypeFile = {\n    schema: {},\n    description: \"\",\n  };\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 }, path: string) {\n  const workspace = await resolveWorkspace(opts);\n  await requireLogin(opts);\n  const rt = await wmill.getResourceType({","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/resource-type/resource-type.ts#L116-L152","documentation":"Sentinel thrown by `wmill resource-type new` when a local file named <name>.resource-type.yaml already exists on disk; creating the template would overwrite it. The try/catch deliberately re-throws this error so the stat 'not found' result falls through to template creation.","triggerScenarios":"Thrown at cli/src/commands/resource-type/resource-type.ts:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a different resource-type name so the generated file path is free.","Delete or rename the existing <name>.resource-type.yaml if it is no longer needed.","If the resource type already exists locally, use `wmill resource-type push <file>` instead of `new`."],"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"}