sxyazi/yazi · error
Linemode must be between 1 and 20 characters long
Error message
Linemode must be between 1 and 20 characters long
What it means
The `linemode` action deserializes into its form, then validates that the new linemode string is 1–20 characters long; empty or longer strings bail with this message. It guards against nonsensical or oversized linemode labels being applied to the manager UI.
Source
Thrown at yazi-parser/src/mgr/linemode.rs:19
use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use serde::Deserialize;
use yazi_shared::event::ActionCow;
#[derive(Debug, Deserialize)]
pub struct LinemodeForm {
#[serde(alias = "0")]
pub new: String,
}
impl TryFrom<ActionCow> for LinemodeForm {
type Error = anyhow::Error;
fn try_from(a: ActionCow) -> Result<Self, Self::Error> {
let me: Self = a.deserialize()?;
if me.new.is_empty() || me.new.len() > 20 {
bail!("Linemode must be between 1 and 20 characters long");
}
Ok(me)
}
}
impl FromLua for LinemodeForm {
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
}
impl IntoLua for LinemodeForm {
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
}
View on GitHub (pinned to 5f901b886b)
Solutions
- Pass a linemode name between 1 and 20 bytes.
- Trim or truncate the custom linemode label before emitting the action.
- If using a multibyte label, keep total byte length ≤ 20 (e.g. slice on char boundaries).
Example fix
-- before (Lua)
ya.manager_emit("linemode", { mode }) -- mode may be ""
-- after
if mode ~= nil and #mode > 0 and #mode <= 20 then
ya.manager_emit("linemode", { mode })
end Defensive patterns
Strategy: validation
Validate before calling
assert!(!new.is_empty() && new.len() <= 20, "linemode name must be 1..=20 bytes");
Type guard
fn is_valid_linemode(s: &str) -> bool {
!s.is_empty() && s.len() <= 20
} Try / catch
match LinemodeForm::try_from(action) {
Ok(form) => apply(form),
Err(e) if e.to_string().contains("Linemode must be between") => {
eprintln!("linemode name out of range: {e}")
}
Err(e) => return Err(e),
} Prevention
- Truncate or trim custom linemode names to ≤20 bytes before emitting.
- Remember the limit is bytes, not chars — multibyte labels count more.
- Handle empty lookups (mode == nil/"") by skipping the emit.
When it happens
Trigger: Calling the `mgr:linemode` action with `new` = "" or a string longer than 20 characters (length measured in bytes via `str::len`).
Common situations: Keymap/config or Lua plugin passing an empty linemode after a failed lookup; long custom linemode names exceeding 20 bytes; multi-byte UTF-8 names where byte length exceeds 20 despite few characters.
Related errors
- Invalid 'summary' in UpdateProgressForm
- Invalid 'cfg' in ShowForm
- Invalid 'token' in ShowForm
- The cursor position is out of bounds.
- Invalid condition: {expr}
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/fe1ac9365cc31de3.
Report an issue: GitHub.