{"record":{"id":"a24be75ecb1103b7","repo":"sxyazi/yazi","slug":"trash-item-has-no-put-back-location-a24be7","errorCode":null,"errorMessage":"trash item has no put-back location","messagePattern":"trash item has no put-back location","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"yazi-fs/src/trash/macos/ds_store.rs","lineNumber":42,"sourceCode":"\n\t\t\tlet location = locations.entry_ref(OsStr::new(&record.name)).or_default();\n\t\t\tmatch &record.field.fourcc().bytes() {\n\t\t\t\tb\"ptbL\" => location.parent = Some(value.into()),\n\t\t\t\tb\"ptbN\" => location.name = Some(value.into()),\n\t\t\t\t_ => {}\n\t\t\t}\n\t\t}\n\n\t\tOk(locations)\n\t}\n\n\tpub(super) fn join(&self, rel: &Path) -> io::Result<PathBuf> {\n\t\tif !rel.is_relative() || rel.has_parent_component() {\n\t\t\treturn Err(io::Error::new(io::ErrorKind::InvalidInput, \"invalid trash entry path\"));\n\t\t}\n\n\t\tlet parent = self.parent.as_deref().ok_or_else(|| {\n\t\t\tio::Error::new(io::ErrorKind::InvalidData, \"trash item has no put-back location\")\n\t\t})?;\n\n\t\tlet name = self.name.as_deref().ok_or_else(|| {\n\t\t\tio::Error::new(io::ErrorKind::InvalidData, \"trash item has no put-back name\")\n\t\t})?;\n\n\t\tlet mut components = Path::new(name).components();\n\t\tif !matches!(components.next(), Some(Component::Normal(_))) || components.next().is_some() {\n\t\t\treturn Err(io::Error::new(io::ErrorKind::InvalidData, \"invalid trash put-back name\"));\n\t\t}\n\n\t\tlet top_path = Path::new(\"/\").join(parent).join(name);\n\t\tOk(if rel.as_os_str().is_empty() { top_path } else { top_path.join(rel) })\n\t}\n}\n","sourceCodeStart":24,"sourceCodeEnd":58,"githubUrl":"https://github.com/sxyazi/yazi/blob/94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2/yazi-fs/src/trash/macos/ds_store.rs#L24-L58","documentation":"Thrown by DsStore::join on macOS when the ~/.Trash/.DS_Store record for a trashed item has no ptbL ('put-back location') field, so the original parent directory is unknown. Finder writes ptbL/ptbN when it moves an item to the Trash; anything that bypasses Finder leaves the record incomplete. Inside yazi the error is caught with .ok() during list()/entry(), so it degrades the entry to original == None instead of propagating.","triggerScenarios":"DsStore::parse finds a record for the file name in ~/.Trash/.DS_Store, but only non-ptbL fields (or nothing) exist for it; ds.join(rel) is then called during Trash::list (root listing) or Trash::entry, hitting self.parent == None.","commonSituations":"User moved a file into ~/.Trash with `mv` from a shell or script; a third-party 'trash' CLI that does not write .DS_Store; .DS_Store was reset by a disk-cleanup tool; item was trashed from a non-root volume where Finder stores put-back info elsewhere.","solutions":["Do not rely on put-back for this item: restore it manually by moving it out of ~/.Trash, or use Trash:rename to place it at the desired path.","If Finder put-back is required, move the item back out and re-trash it from Finder so .DS_Store gets fresh ptbL/ptbN records.","In code, check entry.original (Lua) / entry.original (Rust field) for None before calling restore, and skip or prompt for a destination.","Inspect ~/.Trash/.DS_Store (e.g. `xattr`/hex dump or ds_parser) to confirm the ptbL field is missing for the affected name."],"exampleFix":"-- Lua: before\nya.fs(\"trash\"):restore(entries)\n-- after: only restore entries that carry put-back info\nlocal trash = ya.fs(\"trash\")\nlocal restorable = {}\nfor _, e in ipairs(entries) do\n  if e.original ~= nil then table.insert(restorable, e) end\nend\nif #restorable > 0 then trash:restore(restorable) end","handlingStrategy":"validation","validationCode":"-- Lua: before restoring, require put-back info on every entry\nlocal function has_put_back(e) return e.original ~= nil end\nlocal restorable = vim.tbl_filter(has_put_back, entries) -- or a plain loop","typeGuard":"-- Lua\nlocal function is_restorable(e)\n  return type(e) == \"table\" and e.original ~= nil\nend","tryCatchPattern":"local ok, err = trash:restore(entries)\nif not ok and tostring(err):find(\"put-back\", 1, true) then\n  -- offer manual move out of ~/.Trash instead of retrying\nend","preventionTips":["Trash files from Finder (or an API that writes .DS_Store) when put-back matters.","Never `mv` into ~/.Trash if you intend to restore later; use yazi's trash action or `osascript` Finder delete.","Treat original == nil entries as manually restorable in plugin UI."],"tags":["trash","macos","ds-store","put-back","metadata"],"backgroundTag":null,"analyzedSha":"94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2","analyzedAt":"2026-08-16T09:56:24.836Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}