astrid-runtime/astrid · warning

private atomic-file backend is selected by Windows callers o

Error message

private atomic-file backend is selected by Windows callers only

What it means

atomic_write_private_file() dispatches to the Unix or Windows atomic write backend; there is no generic implementation. On any other target it returns io::ErrorKind::Unsupported because choosing an atomic, permission-preserving replace backend requires platform support.

Source

Thrown at crates/astrid-core/src/platform_fs.rs:381

///
/// Returns an error if the parent is not private, the destination is
/// redirected or permissive, staging or sync fails, or atomic replacement
/// fails.
pub fn atomic_write_private_file(path: &Path, bytes: &[u8]) -> io::Result<()> {
    #[cfg(windows)]
    {
        windows::atomic_write_private_file(path, bytes)
    }

    #[cfg(unix)]
    {
        atomic_write_private_file_unix(path, bytes)
    }

    #[cfg(not(any(unix, windows)))]
    {
        let _ = (path, bytes);
        Err(io::Error::new(
            io::ErrorKind::Unsupported,
            "private atomic-file backend is selected by Windows callers only",
        ))
    }
}

/// Reject redirecting path components at a security-sensitive boundary.
///
/// Windows checks the reparse attribute on every existing component, covering
/// symlinks, junctions, and mount points. It also rejects parent owners or ACLs
/// that let untrusted principals replace checked components, and identity-locks
/// the chain while validating it. Unix opens the nearest existing directory
/// authority and rejects a redirect at the requested or nearest-existing path;
/// callers retain directory capabilities across multi-step mutations.
///
/// # Errors
///
/// Returns an error if an existing security-sensitive path is redirected,

View on GitHub (pinned to affd8760f4)

Solutions

  1. Use plain std::fs::write (accepting weaker guarantees) on unsupported targets, or gate atomic writes to unix/windows.
  2. Branch at the call site on cfg!(any(unix, windows)) and provide a fallback strategy for other targets.
  3. Implement a new platform backend in platform_fs.rs if atomic private writes must work on that target.

Example fix

// before
atomic_write_private_file(&path, &bytes)?;
// after
#[cfg(any(unix, windows))]
atomic_write_private_file(&path, &bytes)?;
#[cfg(not(any(unix, windows)))]
std::fs::write(&path, &bytes)?;
Defensive patterns

Strategy: fallback

Validate before calling

let supported = cfg!(any(unix, windows));
if supported {
    atomic_write_private_file(&path, &bytes)?;
} else {
    std::fs::write(&path, &bytes)?;
}

Type guard

fn supports_atomic_private_write() -> bool { cfg!(any(unix, windows)) }

Try / catch

match atomic_write_private_file(&path, &bytes) {
    Err(e) if e.kind() == io::ErrorKind::Unsupported => std::fs::write(&path, &bytes)?,
    other => other?,
}

Prevention

When it happens

Trigger: Calling atomic_write_private_file(path, bytes) on a non-unix/non-windows target — including indirect calls from journal publication, private create/write, and reader revalidation flows.

Common situations: Building the crate for wasm or an unsupported OS and attempting to write Astrid private state files; a caller that assumes the atomic-write API is portable.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/90505d283346eb7f. Report an issue: GitHub.