{"record":{"id":"c7baf0ab904fb3dc","repo":"sxyazi/yazi","slug":"invaliddata-c7baf0","errorCode":"InvalidData","errorMessage":"trash item has no put-back location","messagePattern":"trash item has no put-back location","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","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/8ebf930f1796ae2076b7d6b0c5e93a1002c18134/yazi-fs/src/trash/macos/ds_store.rs#L24-L58","documentation":"To restore a macOS trashed item, DsStore needs the put-back location (ptbL field) recorded in .DS_Store. When the DsStore entry for the item has parent = None — no ptbL record was found for that item name — join cannot reconstruct the original path and returns this InvalidData error.","triggerScenarios":"Restoring an item whose name has no ptbL record in the trash's .DS_Store — e.g. the .DS_Store lacks put-back data for that item, only ptbN was recorded, the record value was empty (skipped during parse), or a freshly created/truncated .DS_Store.","commonSituations":"Items dragged to trash by tools that don't write put-back metadata; Finder's .DS_Store regenerated or deleted, losing ptbL/ptbN records; third-party trash utilities bypassing Finder metadata; very new trashed items whose metadata wasn't flushed.","solutions":["Fall back to a manual restore: move the item from ~/.Trash to the desired location yourself since macOS metadata is missing.","Open the item in Finder and use \"Put Back\" so Finder reconstructs/uses its own metadata, then retry.","Check that the trash's .DS_Store still contains ptbL records for the item (parse it with a .DS_Store inspector).","If .DS_Store was deleted or regenerated, put-back data is unrecoverable — restore manually."],"exampleFix":"// before: assuming put-back data always exists\nlet dest = ds_store.join(rel)?;\n// after: degrade gracefully when put-back metadata is absent\nlet dest = match ds_store.join(rel) {\n    Ok(dest) => dest,\n    Err(_) => trash_dir.join(rel), // fallback: restore in place\n};","handlingStrategy":"fallback","validationCode":"fn has_put_back_metadata(store: &DsStore, name: &std::ffi::OsStr) -> bool {\n    // parent (ptbL) must be present for restore to be possible\n    store.can_restore(name) // expose a predicate or check the parsed ptbL record\n}","typeGuard":null,"tryCatchPattern":"let dest = match ds_store.join(&rel) {\n    Ok(dest) => dest,\n    Err(e) if e.to_string().contains(\"no put-back location\") => {\n        eprintln!(\"no Finder put-back data; restoring to trash-relative path\");\n        trash_dir.join(&rel)\n    }\n    Err(e) => return Err(e.into()),\n};","preventionTips":["Check for put-back metadata availability before offering restore.","Don't delete or regenerate .DS_Store inside the trash — it holds ptbL/ptbN records.","Prevent third-party tools from bypassing Finder when moving items to trash if restore is expected.","Provide a manual move-to-location fallback in restore UIs."],"tags":["filesystem","trash","macos","missing-metadata"],"backgroundTag":"missing-put-back-metadata","analyzedSha":"8ebf930f1796ae2076b7d6b0c5e93a1002c18134","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}