tinyhumansai/openhuman · error

target path has no parent directory

Error message

target path has no parent directory

What it means

Atomic-write helper guard: the target file path has no parent directory component (it resolves to a filesystem root), so no sibling temp file can be staged for the rename-based atomic replace. A path-shape problem, not a permission one.

Source

Thrown at src/openhuman/tools/impl/filesystem/update_memory_md.rs:106

        file.lock_exclusive()
            .map_err(|e| anyhow::anyhow!("acquire workspace write flock: {e}"))?;
        Ok::<std::fs::File, anyhow::Error>(file)
    })
    .await
    .map_err(|e| anyhow::anyhow!("workspace lock task join failed: {e}"))?
}

/// Atomically replace `path`'s contents with `content`.
///
/// Writes to a sibling temp file in the same directory (so the rename stays on
/// one filesystem and is atomic) and `rename`s it over the target. A crash
/// mid-write leaves either the old file or the complete new file — never a
/// half-written truncation. Callers MUST hold the per-workspace write lock so
/// the read-modify-write is serialized end-to-end.
async fn atomic_write(path: &Path, file: &str, content: &str) -> anyhow::Result<()> {
    let dir = path
        .parent()
        .ok_or_else(|| anyhow::anyhow!("target path has no parent directory"))?;
    let seq = TEMP_FILE_SEQ.fetch_add(1, Ordering::Relaxed);
    let tmp_name = format!(".{file}.{}.{seq}.tmp", std::process::id());
    let tmp_path = dir.join(tmp_name);

    tracing::debug!(
        tmp = %tmp_path.display(),
        target = %path.display(),
        bytes = content.len(),
        "[update_memory_md] atomic write: staging temp file"
    );

    if let Err(e) = tokio::fs::write(&tmp_path, content).await {
        // Clean up a partially-written temp file so a failed stage doesn't
        // litter the workspace (CodeRabbit: temp not cleaned on initial write).
        let _ = tokio::fs::remove_file(&tmp_path).await;
        return Err(anyhow::anyhow!("Failed to stage temp file for {file}: {e}"));
    }

View on GitHub (pinned to 7491200858)

Solutions

  1. Pass a real file path with a directory component rather than a bare root
  2. Use a path under the workspace memory directory
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/tools/impl/filesystem/update_memory_md.rs:106 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/5b14ab62470f3e8d. Report an issue: GitHub.