windmill-labs/windmill · error

File already exists: + filePath

Error message

File already exists: + filePath

What it means

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.

Source

Thrown at cli/src/commands/resource-type/resource-type.ts:134

          JSON.stringify(x.schema, null, 2),
        ])
      )
      .render();
  } else {
    new Table()
      .header(["Workspace", "Name"])
      .padding(2)
      .border(true)
      .body(res.map((x) => [x.workspace_id ?? "Global", x.name]))
      .render();
  }
}

async function newResourceType(opts: GlobalOptions, name: string) {
  const filePath = name + ".resource-type.yaml";
  try {
    await stat(filePath);
    throw new Error("File already exists: " + filePath);
  } catch (e: any) {
    if (e.message?.startsWith("File already exists")) throw e;
  }
  const template: ResourceTypeFile = {
    schema: {},
    description: "",
  };
  await writeFile(filePath, yamlStringify(template as Record<string, any>), {
    flag: "wx",
    encoding: "utf-8",
  });
  log.info(colors.green(`Created ${filePath}`));
}

async function get(opts: GlobalOptions & { json?: boolean }, path: string) {
  const workspace = await resolveWorkspace(opts);
  await requireLogin(opts);
  const rt = await wmill.getResourceType({

View on GitHub (pinned to e474e8803c)

Solutions

  1. Choose a different resource-type name so the generated file path is free.
  2. Delete or rename the existing <name>.resource-type.yaml if it is no longer needed.
  3. If the resource type already exists locally, use `wmill resource-type push <file>` instead of `new`.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cli/src/commands/resource-type/resource-type.ts:134 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/b3c40370c7b0c37e. Report an issue: GitHub.