Hmbown/CodeWhale · warning · ExecError

open_application needs name, bundle_id or pid

Error message

open_application needs name, bundle_id or pid

What it means

openApplication resolves an application by name, bundle_id, or pid; the library requires at least one identity and throws this immediately when all three are absent/undefined. As a guard it also clears any previously armed foreground-input binding before failing.

Solutions

  1. Pass at least one of name, bundle_id, or pid.
  2. Prefer pid when you have it — it is the only identity that distinguishes two processes of the same bundle.
  3. Run list_apps first to obtain exact names/pids.
  4. Fix key spelling: the bundle identifier parameter is bundle_id (snake_case), not bundleId.

Example fix

// before
await backend.openApplication({});
// after
await backend.openApplication({ bundle_id: "com.google.Chrome" });
Defensive patterns

Strategy: validation

Validate before calling

const hasIdentity = a => !!(a && (a.name || a.bundle_id || a.pid));
if (!hasIdentity(args)) throw new Error('open_application requires name, bundle_id or pid');

Type guard

const isOpenArgs = a => a != null && (typeof a.name === 'string' || typeof a.bundle_id === 'string' || Number.isInteger(a.pid));

Try / catch

try {
  await backend.openApplication(args);
} catch (e) {
  if (String(e.message).startsWith('open_application needs')) {
    // fix arguments before retrying
  } else throw e;
}

Prevention

When it happens

Trigger: Calling open_application with no arguments, an empty object, or where the variables holding name/bundle_id/pid are all undefined at the call site.

Common situations: Constructing arguments dynamically from upstream data where all fields happen to be missing; passing the object with misspelled keys (e.g. bundleId instead of bundle_id); an agent emitting an open_application tool call with empty parameters.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/2271cd3ee88234e9. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/plugins/computer-use/src/backends/darwin.mjs:763

        installed: true,
        note: "Installed catalog from /Applications, /System/Applications and ~/Applications; running flags reflect this moment. This scan takes a moment.",
      };
    }
    const r = await native("list_apps");
    const apps = Array.isArray(r?.apps) ? r.apps : [];
    const shown = selectApps(apps, args?.all === true);
    return {
      apps: shown,
      total: apps.length,
      filtered: args?.all === true ? "all" : "regular",
      ...(shown.length !== apps.length ? { note: "Regular (user-facing) apps only — pass all:true to include menu-bar helpers and background processes." } : {}),
    };
  }

  async function listWindows({ app_ref } = {}) { return native("list_windows", { app_ref: app_ref === undefined ? state.inputApp ?? undefined : app_ref }); }

  async function openApplication({ name, bundle_id: bid, pid, url: urlArg, activate = false } = {}) {
    if (!name && !bid && !pid) throw new ExecError("open_application needs name, bundle_id or pid");
    // Failed selection must not leave an earlier app armed for shared input.
    state.foregroundInput = false;
    state.inputApp = null;
    // pid is the most specific identity and the only one that separates two
    // processes of the same bundle (e.g. a second Chrome on its own profile),
    // so it wins when given.
    const find = {};
    if (pid) find.pid = pid; else if (bid) find.bundle_id = bid; else find.name = String(name).replace(/\.app$/, "");
    let p;
    let launched = false;
    // Binding an already-running app must not ask LaunchServices to reopen
    // it: reopen can raise windows even with open -g on some applications.
    if (!urlArg) {
      try { p = await native("app_info", { app_ref: find, activate }); }
      catch (error) {
        if (!error.message.includes("application not found")) throw error;
      }
    }

View on GitHub (pinned to 73e0f67d83)