sxyazi/yazi · error

not a list of Files

Error message

not a list of Files

What it means

TryFrom<Data> for Files requires the Data value to be the List variant whose elements each convert into a File. The bail fires when the Data is any other variant (e.g. a string, integer, or map). It is a shape/type validation error when converting plugin-provided or deserialized data into a file list.

Source

Thrown at yazi-fs/src/file/data.rs:29

	fn try_from(value: Data) -> Result<Self, Self::Error> {
		value.into_any::<Self>().ok_or_else(|| anyhow!("not a File"))
	}
}

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

	fn try_from(value: &Data) -> Result<Self, Self::Error> {
		value.as_any::<Self>().cloned().ok_or_else(|| anyhow!("not a File"))
	}
}

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

	fn try_from(value: Data) -> Result<Self, Self::Error> {
		let Data::List(files) = value else { bail!("not a list of Files") };
		files.into_iter().map(File::try_from).collect::<Result<_, _>>().map(Self)
	}
}

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

	fn try_from(value: &Data) -> Result<Self, Self::Error> {
		let Data::List(files) = value else { bail!("not a list of Files") };
		files.iter().map(File::try_from).collect::<Result<_, _>>().map(Self)
	}
}

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Inspect the Data variant actually produced by your fetch/preload plugin and ensure it returns a list of File-shaped tables.
  2. Match the expected schema for the plugin type you are implementing (check docs/examples of existing fetchers).
  3. Add a shape check on the producer side so bad payloads are rejected with a clearer message.

Example fix

// before (Lua fetcher)
return fields -- single table
// after
return { fields } -- list of File tables
Defensive patterns

Strategy: type-guard

Validate before calling

// Lua plugin side: ensure a list of file tables is returned
local ok = type(result) == "table" and #result > 0 and type(result[1]) == "table"

Type guard

// Rust: narrow the Data variant before converting
fn as_file_list(data: &Data) -> Option<&Vec<Data>> {
    match data { Data::List(items) => Some(items), _ => None }
}

Try / catch

let files = Files::try_from(data).map_err(|e| anyhow!("fetcher returned invalid payload: {e}"))?;

Prevention

When it happens

Trigger: Calling Files::try_from(data) with a Data built from a scalar (Data::String, Data::Integer, etc.) instead of Data::List of File-convertible values; a fetch/preloader returning the wrong payload shape.

Common situations: A Lua fetch/preload plugin returning a single table-of-fields or a string instead of a list of file tables; protocol/config changes where the payload schema changed between versions.

Related errors


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