sxyazi/yazi · error

empty key

Error message

empty key

What it means

A validation guard in Key::from_str: keymap configuration strings are parsed into Key structs, and an empty string cannot denote any key. It fires when a keymap entry contains an empty key specification — typically a config mistake such as an empty `on` value or `<`/`>` markup that reduced to nothing — and prevents constructing a Key with an undefined code.

Source

Thrown at yazi-config/src/keymap/key.rs:56

			None => (value.code, value.modifiers.contains(Modifiers::SHIFT)),
		};

		Self {
			code,
			shift,
			ctrl: value.modifiers.contains(Modifiers::CONTROL),
			alt: value.modifiers.contains(Modifiers::ALT),
			super_: value.modifiers.contains(Modifiers::SUPER),
		}
	}
}

impl FromStr for Key {
	type Err = anyhow::Error;

	fn from_str(s: &str) -> Result<Self, Self::Err> {
		if s.is_empty() {
			bail!("empty key")
		}

		let mut key = Self::default();
		if !s.starts_with('<') || !s.ends_with('>') {
			key.code = KeyCode::Char(s.chars().next().unwrap());
			key.shift = matches!(key.code, KeyCode::Char(c) if c.is_uppercase());
			return Ok(key);
		}

		let mut it = s[1..s.len() - 1].split_inclusive('-').peekable();
		while let Some(next) = it.next() {
			match next.to_ascii_lowercase().as_str() {
				"s-" => key.shift = true,
				"c-" => key.ctrl = true,
				"a-" => key.alt = true,
				"d-" => key.super_ = true,

				"space" => key.code = KeyCode::Char(' '),

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Provide a non-empty key string in the keymap.
  2. Remove the empty keybinding entry from keymap.toml.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at yazi-config/src/keymap/key.rs:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/107cd79141cf56c6. Report an issue: GitHub.