windmill-labs/windmill · error · Error

User ${email} not found

Error message

User ${email} not found

What it means

`wmill sync delete` maps a users/<email>.user.json file back to a remote user. It first fetches the user list from the remote workspace and looks up the user by email; if none matches, it throws this error rather than calling deleteUser with a fabricated username. The remote username is required for the delete API.

Source

Thrown at cli/src/commands/sync/sync.ts:6436

                    } else {
                      throw e;
                    }
                  }
                  deletedVarsResPaths.push(variablePath);
                  break;
                }
                case "user": {
                  const users = await wmill.listUsers({
                    workspace: workspaceId,
                  });

                  const email = removeSuffix(
                    removePathPrefix(change.path, "users"),
                    ".user.json",
                  );
                  const user = users.find((u) => u.email === email);
                  if (!user) {
                    throw new Error(`User ${email} not found`);
                  }
                  await wmill.deleteUser({
                    workspace: workspaceId,
                    username: user.username,
                  });
                  break;
                }
                case "group":
                  await wmill.deleteGroup({
                    workspace: workspaceId,
                    name: removeSuffix(
                      removePathPrefix(change.path, "groups"),
                      ".group.json",
                    ),
                  });
                  break;
                case "workspace_dependencies":
                  const relativePath = removePathPrefix(

View on GitHub (pinned to e474e8803c)

Solutions

  1. Verify you are on the intended workspace (`wmill switch` / --workspace flag)
  2. Confirm the user still exists in the workspace settings; if already deleted, remove the stale local file and re-sync
  3. Re-run `wmill sync pull` to refresh users from the remote
  4. Check email spelling/case matches the remote user exactly

Example fix

// before: stale local file drives delete
users/left@company.com.user.json  (user already removed remotely)
// after: prune stale state then delete
wmill sync pull && rm users/left@company.com.user.json && wmill sync delete
Defensive patterns

Strategy: validation

Validate before calling

const remote = await wmill.listUsers({ workspace: workspaceId });
const exists = remote.some(u => u.email === "foo@bar.com");
if (!exists) throw new Error("skip delete: user absent remotely");

Try / catch

try {
  await wmill.sync.delete(opts);
} catch (e) {
  if (/^User .* not found$/.test(String(e.message))) {
    // stale local file — prune and continue
    fs.rmSync(localUserFile);
  }
}

Prevention

When it happens

Trigger: Running a sync delete where the local file users/foo@bar.com.user.json exists but the remote workspace has no user with email foo@bar.com — e.g. the user was already deleted remotely, renamed, or the CLI is pointed at the wrong workspace.

Common situations: Pointing at a different workspace than the one the sync folder was pulled from; user deleted by an admin out-of-band; email casing mismatch after a remote rename.

Related errors


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