sxyazi/yazi · error

Invalid MoveOptStep data type: {value:?}

Error message

Invalid MoveOptStep data type: {value:?}

What it means

`MoveOptStep`'s `TryFrom<&Data>` impl accepts only a String (parsed via FromStr, e.g. "half-page", "-1", "100%"-style specs) or an Integer (interpreted as a line count). Any other Data variant — Bool, Number (float), List, Map, Null — bails with "Invalid MoveOptStep data type: {value:?}", including the value's Debug form.

Source

Thrown at yazi-widgets/src/input/parser/move.rs:82

			"eol" => Self::Eol,
			"first-char" => Self::FirstChar,
			s => Self::Offset(s.parse()?),
		})
	}
}

impl From<isize> for MoveOptStep {
	fn from(value: isize) -> Self { Self::Offset(value) }
}

impl TryFrom<&Data> for MoveOptStep {
	type Error = anyhow::Error;

	fn try_from(value: &Data) -> Result<Self, Self::Error> {
		Ok(match value {
			Data::String(s) => s.parse()?,
			Data::Integer(i) => Self::from(*i as isize),
			_ => bail!("Invalid MoveOptStep data type: {value:?}"),
		})
	}
}

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Pass the step as an integer (line count) or a recognized string form (e.g. "half-page").
  2. Check the keymap/Lua call site and correct the argument's type; remove surrounding tables/lists.
  3. For fractional scrolling, round to an integer or use the string preset instead of a float.
  4. For absent optional steps, omit the key and rely on the handler's default rather than passing nil.

Example fix

// before
-- keymap: { run = 'input move 1.5' }  -> Data::Number -> invalid
// after
{ run = 'input move 1' }        -- integer
-- or
{ run = 'input move half-page' } -- string preset
Defensive patterns

Strategy: validation

Validate before calling

fn valid_step(d: &Data) -> bool {
    match d {
        Data::String(s) => s.parse::<MoveOptStep>().is_ok(),
        Data::Integer(_) => true,
        _ => false,
    }
}

Type guard

fn is_step_data(d: &Data) -> bool {
    matches!(d, Data::String(_) | Data::Integer(_))
}

Try / catch

let step = MoveOptStep::try_from(&data).unwrap_or(MoveOptStep::from(1));

Prevention

When it happens

Trigger: Passing a non-string/non-integer value where a step spec is expected — e.g. `Data::Number(1.5)`, `Data::Bool(true)`, or a missing (Null) argument converted via `TryFrom<&Data>` in input-widget movement handling (cursor move by step).

Common situations: Keymap/config `input` movement bindings where the step argument is a float or boolean instead of an integer or string like "half-page"; Lua plugin calls passing numbers with fractional parts or nil; typos in config that leave the argument as a table.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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