gitbutlerapp/gitbutler · error

id or name must be specified

Error message

id or name must be specified

What it means

Input validation when opening a tool/program: neither an id nor a name was supplied to identify which built-in tool to open. The match on (self.name, self.id) reached the arm where both are None and there is no builtin to fall back to, so the CLI cannot determine which tool to launch.

Solutions

  1. Include at least `name` in the program payload
  2. Or include `id` if the client knows it
  3. If only `executable` is known, derive id/name from the executable path before calling

Example fix

// before
{ "executable": "/usr/bin/code" }
// after
{ "name": "Visual Studio Code", "id": "com.microsoft.vscode", "executable": "/usr/bin/code" }
Defensive patterns

Strategy: validation

Validate before calling

if (program.name == null && program.id == null) throw new Error('id or name must be specified');

Type guard

function hasIdentity(p: {name?: string|null, id?: string|null}): boolean { return p.name != null || p.id != null; }

Try / catch

try { await resolveProgram(program); } catch (e) { if (String(e).includes('id or name must be specified')) { /* prompt user for a name */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling the ProgramSpec builder (resolve/sanitize path for non built-in programs) with neither `name` nor `id` set on the input struct.

Common situations: Clients constructing a custom open-with program from partial UI data, deserializing a JSON payload that omitted both identifying fields, or a frontend sending only `executable`.

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 gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/40318b9e1a6e663d. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-api/src/open/program.rs:741

                id: id.clone(),
                name: self.name.unwrap_or_else(|| builtin.name.clone()),
                executable: self
                    .executable
                    .map(Into::into)
                    .unwrap_or_else(|| builtin.executable.clone()),
                category: self
                    .category
                    .map(Into::into)
                    .unwrap_or_else(|| builtin.category.clone()),
                cli_arg_supplier,
                extensions,
            })
        } else {
            let (name, id) = match (self.name, self.id) {
                (Some(name), Some(id)) => (name, id),
                (Some(name), None) => (name.clone(), name),
                (None, Some(id)) => (id.clone(), id),
                (None, None) => anyhow::bail!("id or name must be specified"),
            };

            let Some(executable) = self.executable else {
                anyhow::bail!("executable must be specified for non built-ins")
            };

            Ok(ProgramSpec {
                id,
                name,
                executable: executable.into(),
                category: self.category.map(Into::into).unwrap_or_default(),
                cli_arg_supplier: CliArgumentSupplier::Custom(CustomCliArgumentSupplier {
                    open_args: self.open_args,
                    open_at_line_args: self.open_at_line_args,
                }),
                extensions,
            })
        }

View on GitHub (pinned to 58e5313667)