xai-org/grok-build · error · anyhow::Error

cannot derive metadata path for {}

Error message

cannot derive metadata path for {}

What it means

Error "cannot derive metadata path for {}" thrown in xai-org/grok-build.

Source

Thrown at crates/codegen/xai-fast-worktree/src/btrfs/snapshot.rs:452

/// `".grok-snapshots"` is used when the btrfs mount IS the repo subvolume
/// (dot-prefixed to stay hidden from git).
pub const BTRFS_SNAPSHOT_SUBDIRS: &[&str] = &["worktrees", ".grok-snapshots"];

/// Compute the sibling metadata file path for a snapshot directory.
pub fn btrfs_meta_path(snapshot_path: &Path) -> Option<PathBuf> {
    let parent = snapshot_path.parent()?;
    let name = snapshot_path.file_name()?.to_str()?;
    Some(parent.join(format!("{name}{BTRFS_META_SUFFIX}")))
}

/// Write recovery metadata for a btrfs snapshot next to it on disk.
///
/// Public so the privileged snapshot delegate persists the same
/// metadata the in-process path does; without it a snapshot whose `mount_target`
/// symlink is lost is invisible to the orphan scanners and leaks.
pub fn write_btrfs_metadata(snapshot_path: &Path, mount_target: &Path) -> Result<()> {
    let meta_path = btrfs_meta_path(snapshot_path).ok_or_else(|| {
        anyhow::anyhow!(
            "cannot derive metadata path for {}",
            snapshot_path.display()
        )
    })?;

    let meta = BtrfsSnapshotMetadata {
        kind: Cow::Borrowed("btrfs"),
        snapshot_path: snapshot_path.to_path_buf(),
        mount_target: mount_target.to_path_buf(),
        created_at: crate::util::unix_timestamp_string(),
    };

    let content =
        serde_json::to_string_pretty(&meta).context("serialize btrfs snapshot metadata")?;
    std::fs::write(&meta_path, content)
        .with_context(|| format!("write btrfs metadata to {}", meta_path.display()))?;

    tracing::debug!(path = %meta_path.display(), "btrfs snapshot metadata written");

View on GitHub (pinned to bc7f02eddd)

When it happens

Trigger: Thrown at crates/codegen/xai-fast-worktree/src/btrfs/snapshot.rs:452 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/4405854127830e5a. Report an issue: GitHub.