{"record":{"id":"95b87345022bbf7d","repo":"windmill-labs/windmill","slug":"file-already-exists-filepath-95b873","errorCode":null,"errorMessage":"File already exists: ${filePath}","messagePattern":"File already exists: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/variable/variable.ts","lineNumber":58,"sourceCode":"        variables.map((x) => [\n          x.path,\n          x.is_secret ? \"true\" : \"false\",\n          x.account ?? \"-\",\n          x.value ?? \"-\",\n        ])\n      )\n      .render();\n  }\n}\n\nasync function newVariable(opts: GlobalOptions, path: string) {\n  if (!validatePath(path)) {\n    return;\n  }\n  const filePath = path + \".variable.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: VariableFile = {\n    value: \"\",\n    is_secret: false,\n    description: \"\",\n  };\n  await mkdir(dirname(filePath), { 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 }, path: string) {\n  if (opts.json) log.setSilent(true);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/variable/variable.ts#L40-L76","documentation":"`wmill variable new` refuses to write its template because <path>.variable.yaml already exists locally; generating it would clobber the existing definition. The catch block re-throws this sentinel while letting ENOENT fall through to creation.","triggerScenarios":"Thrown at cli/src/commands/variable/variable.ts:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pick a different variable path/name.","Delete or rename the existing file, or edit it directly instead of re-running 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"}