zed-industries/zed · warning · anyhow::Error

Action name is required

Error message

Action name is required

What it means

The keymap editor's get_selected_action_name reads the action-selector text field; when the user opened the action editor but left the name empty, it bails with this validation error (caught by the caller and stored into self.error, then cx.notify() renders it). It is a form-level required-field check, not a system failure.

Source

Thrown at crates/keymap_editor/src/keymap_editor.rs:2725

        if self
            .error
            .as_ref()
            .is_some_and(|old_error| old_error.severity == Severity::Warning && *old_error == error)
        {
            false
        } else {
            self.error = Some(error);
            cx.notify();
            true
        }
    }

    fn get_selected_action_name(&self, cx: &App) -> anyhow::Result<&'static str> {
        if let Some(selector) = self.action_editor.as_ref() {
            let action_name_str = selector.read(cx).text(cx);

            if action_name_str.is_empty() {
                anyhow::bail!("Action name is required");
            }

            self.action_name_to_static
                .get(&action_name_str)
                .copied()
                .ok_or_else(|| anyhow::anyhow!("Action '{}' not found", action_name_str))
        } else {
            Ok(self.editing_keybind.action().name)
        }
    }

    fn validate_action_arguments(&self, cx: &App) -> anyhow::Result<Option<String>> {
        let action_name = self.get_selected_action_name(cx)?;
        let action_arguments = self
            .action_arguments_editor
            .as_ref()
            .map(|arguments_editor| arguments_editor.read(cx).editor.read(cx).text(cx))
            .filter(|args| !args.is_empty());

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Select an action from the editor's autocomplete list before saving
  2. Disable the save button while the selector text is empty
  3. Trim whitespace before the emptiness check so ' ' also reads as missing
  4. If editing an existing binding, keep the current action name pre-filled so the field starts non-empty

Example fix

// before
let action_name_str = selector.read(cx).text(cx);
if action_name_str.is_empty() {
    anyhow::bail!("Action name is required");
}

// after (guard in the UI layer)
let action_name_str = selector.read(cx).text(cx).trim().to_string();
let save_enabled = !action_name_str.is_empty();
// ... .when(!save_enabled, |el| el.opacity(0.5))
Defensive patterns

Strategy: validation

Validate before calling

let name = selector.read(cx).text(cx).trim().to_string();
if name.is_empty() { return Ok(()); } // block save instead of erroring later
let static_name = self.action_name_to_static.get(&name).copied()
    .ok_or_else(|| anyhow::anyhow!("Action '{}' not found", name))?;

Try / catch

if let Err(error) = self.get_selected_action_name(cx) {
    self.error = Some(error); // already the pattern: surface in UI, do not propagate
    cx.notify();
}

Prevention

When it happens

Trigger: Pressing Save/Add on a new keybinding while the action selector is empty (the 'else' branch that would reuse editing_keybind.action().name does not apply because an editor is open with blank text).

Common situations: Users typing a keystroke then hitting save before picking an action; clearing the selector to 'unset' the action; automated UI tests submitting the form unvalidated.

Related errors


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/779fe1b78cd8994f. Report an issue: GitHub.