{"record":{"id":"4405854127830e5a","repo":"xai-org/grok-build","slug":"cannot-derive-metadata-path-for","errorCode":null,"errorMessage":"cannot derive metadata path for {}","messagePattern":"cannot derive metadata path for (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-fast-worktree/src/btrfs/snapshot.rs","lineNumber":452,"sourceCode":"/// `\".grok-snapshots\"` is used when the btrfs mount IS the repo subvolume\n/// (dot-prefixed to stay hidden from git).\npub const BTRFS_SNAPSHOT_SUBDIRS: &[&str] = &[\"worktrees\", \".grok-snapshots\"];\n\n/// Compute the sibling metadata file path for a snapshot directory.\npub fn btrfs_meta_path(snapshot_path: &Path) -> Option<PathBuf> {\n    let parent = snapshot_path.parent()?;\n    let name = snapshot_path.file_name()?.to_str()?;\n    Some(parent.join(format!(\"{name}{BTRFS_META_SUFFIX}\")))\n}\n\n/// Write recovery metadata for a btrfs snapshot next to it on disk.\n///\n/// Public so the privileged snapshot delegate persists the same\n/// metadata the in-process path does; without it a snapshot whose `mount_target`\n/// symlink is lost is invisible to the orphan scanners and leaks.\npub fn write_btrfs_metadata(snapshot_path: &Path, mount_target: &Path) -> Result<()> {\n    let meta_path = btrfs_meta_path(snapshot_path).ok_or_else(|| {\n        anyhow::anyhow!(\n            \"cannot derive metadata path for {}\",\n            snapshot_path.display()\n        )\n    })?;\n\n    let meta = BtrfsSnapshotMetadata {\n        kind: Cow::Borrowed(\"btrfs\"),\n        snapshot_path: snapshot_path.to_path_buf(),\n        mount_target: mount_target.to_path_buf(),\n        created_at: crate::util::unix_timestamp_string(),\n    };\n\n    let content =\n        serde_json::to_string_pretty(&meta).context(\"serialize btrfs snapshot metadata\")?;\n    std::fs::write(&meta_path, content)\n        .with_context(|| format!(\"write btrfs metadata to {}\", meta_path.display()))?;\n\n    tracing::debug!(path = %meta_path.display(), \"btrfs snapshot metadata written\");","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-fast-worktree/src/btrfs/snapshot.rs#L434-L470","documentation":"Error \"cannot derive metadata path for {}\" thrown in xai-org/grok-build.","triggerScenarios":"Thrown at crates/codegen/xai-fast-worktree/src/btrfs/snapshot.rs:452 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}