sxyazi/yazi · warning · io::Error

trash item has no put-back name

Error message

trash item has no put-back name

What it means

Thrown by DsStore::join on macOS when a ~/.Trash/.DS_Store record has a ptbL (put-back parent) but no ptbN ('put-back name') field, so the original file name is unknown. It indicates partially-written or non-Finder trash metadata. Like its sibling error, it is swallowed with .ok() by list()/entry() and manifests as original == None on the entry.

Source

Thrown at yazi-fs/src/trash/macos/ds_store.rs:46

				b"ptbN" => location.name = Some(value.into()),
				_ => {}
			}
		}

		Ok(locations)
	}

	pub(super) fn join(&self, rel: &Path) -> io::Result<PathBuf> {
		if !rel.is_relative() || rel.has_parent_component() {
			return Err(io::Error::new(io::ErrorKind::InvalidInput, "invalid trash entry path"));
		}

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

		let name = self.name.as_deref().ok_or_else(|| {
			io::Error::new(io::ErrorKind::InvalidData, "trash item has no put-back name")
		})?;

		let mut components = Path::new(name).components();
		if !matches!(components.next(), Some(Component::Normal(_))) || components.next().is_some() {
			return Err(io::Error::new(io::ErrorKind::InvalidData, "invalid trash put-back name"));
		}

		let top_path = Path::new("/").join(parent).join(name);
		Ok(if rel.as_os_str().is_empty() { top_path } else { top_path.join(rel) })
	}
}

View on GitHub (pinned to 94abcfa92f)

Solutions

  1. Restore manually by moving the item out of ~/.Trash (its current name in the Trash is usable) or via Trash:rename.
  2. Re-trash the item from Finder to regenerate complete ptbL/ptbN metadata, then restore.
  3. Guard callers: treat entries with original == nil as non-restorable and prompt for a destination path.
Defensive patterns

Strategy: validation

Validate before calling

-- Lua: entries from list() carry original only when BOTH ptbL and ptbN parsed
local restorable = {}
for _, e in ipairs(entries) do
  if e.original ~= nil then table.insert(restorable, e) end
end

Type guard

local function is_restorable(e) return e.original ~= nil end

Try / catch

local ok, err = trash:restore(restorable)
if not ok then ya.notify({ title = "Trash", content = tostring(err), level = "error" }) end

Prevention

When it happens

Trigger: DsStore record for the trash item contains ptbL but lacks ptbN (record.value Ustr entries only matched the b"ptbL" arm), and ds.join() reaches self.name == None.

Common situations: Item trashed by a tool that writes location but not name metadata; .DS_Store corruption or partial rewrite; unusual Finder versions or per-volume .DS_Store behavior after moving disks between machines.

Related errors


AI-assisted analysis of sxyazi/yazi@94abcfa92f (2026-08-16). Data as JSON: /api/errors/e52e6566a9969234. Report an issue: GitHub.