sxyazi/yazi · error · io::Error

NotFound

NotFound

Error message

trash item has no put-back location

What it means

When listing children of a trashed directory on Windows, the entry must know its original (put-back) path to compute the mapping. This error is raised when `entry.original` is None — the trash entry has no recorded original location, so its children cannot be resolved. It indicates a corrupt or incomplete trash entry rather than a transient failure.

Source

Thrown at yazi-fs/src/trash/windows/trash.rs:32

impl Trash {
	pub(crate) fn new() -> io::Result<Self> {
		COM.with(|result| {
			result.as_ref().map(|_| Self).map_err(|e| io::Error::new(e.kind(), e.to_string()))
		})
	}

	pub(crate) fn list(&self, entry: Option<&TrashEntry>) -> io::Result<Vec<TrashEntry>> {
		let Some(entry) = entry else {
			return self.tops();
		};

		if !entry.lcha.is_dir() || entry.lcha.is_indirect() {
			return Err(io::Error::new(io::ErrorKind::InvalidInput, "trash item is not a directory"));
		}

		let original = entry.original.as_deref().ok_or_else(|| {
			io::Error::new(io::ErrorKind::NotFound, "trash item has no put-back location")
		})?;

		self
			.resolve(entry)?
			.children()?
			.into_iter()
			.map(|item| {
				let name = item.display_name(SIGDN_PARENTRELATIVEPARSING)?;
				item.entry(entry.id.child(&name)?, Some(original.join(&name)))
			})
			.collect()
	}

	pub(crate) fn entry(&self, id: &TrashId) -> io::Result<TrashEntry> {
		let top = ShellItem::top(id.top())?;
		let original = top.original()?;
		if !id.has_rel() {
			return top.entry(id.clone(), Some(original));

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Skip entries without an original path and surface them as unrestorable.
  2. Check `entry.original.is_some()` before attempting child listing/restore of the entry.
  3. Repair the recycle-bin record by deleting and re-trashing the item, or restore it via Explorer if possible.
  4. Treat io::ErrorKind::NotFound as data-level unavailability, not a bug in your code.

Example fix

// before
let original = entry.original.as_deref()?;
// after
match entry.original.as_deref() {
    Some(original) => { /* proceed */ }
    None => eprintln!("skipping {} (no put-back location)", entry.key()),
}
Defensive patterns

Strategy: validation

Validate before calling

let Some(original) = entry.original.as_deref() else {
    eprintln!("entry has no put-back location; skipping");
    return Ok(());
};

Type guard

fn has_put_back(entry: &TrashEntry) -> bool { entry.original.is_some() }

Try / catch

match trash.list(Some(&entry)) {
    Ok(children) => children,
    Err(e) if e.kind() == std::io::ErrorKind::NotFound => Vec::new(),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling `Trash::list(Some(entry))` on a directory trash entry whose `original` field is None (the recycle-bin record lacks a put-back path).

Common situations: Recycle-bin metadata missing or damaged (e.g. $R/$I record mismatch), entries restored manually outside the app, entries imported from another drive/user profile.

Understand the failure class

Background: "Not Found" / HTTP 404 Errors: What They Mean and How to Fix Them Across Libraries — this error's family across 6 libraries.

Related errors


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