astrid-runtime/astrid · error

invalid parent PID

Error message

invalid parent PID

What it means

validate_launch_parent, invoked from validate_launch, checks the parent lifetime record supplied when launching the FSKit helper process. A parent pid of 0/1 or the provider's own pid is rejected, because such values cannot represent a real supervising process to monitor. This prevents launching without a meaningful lifetime owner.

Source

Thrown at crates/astrid-storage-provider-fskit/src/service.rs:399

}

#[cfg(target_os = "macos")]
fn mac_process_start_identity(pid: u32) -> Option<String> {
    use libproc::libproc::bsd_info::BSDInfo;
    use libproc::libproc::proc_pid::pidinfo;

    let info = pidinfo::<BSDInfo>(i32::try_from(pid).ok()?, 0).ok()?;
    Some(format!(
        "{}:{}",
        info.pbi_start_tvsec, info.pbi_start_tvusec
    ))
}

fn validate_launch_parent(
    parent: &astrid_core::storage_filesystem::StorageProviderParentLifetimeV1,
) -> Result<()> {
    if parent.pid <= 1 || parent.pid == std::process::id() {
        bail!("invalid parent PID");
    }
    if parent.token.len() < 16
        || parent.token.len() > 512
        || parent.token.chars().any(char::is_control)
    {
        bail!("invalid parent token");
    }
    if let Some(identity) = parent.start_identity.as_deref()
        && (identity.is_empty() || identity.len() > 512 || identity.chars().any(char::is_control))
    {
        bail!("invalid parent start identity");
    }
    #[cfg(any(target_os = "linux", target_os = "macos"))]
    if parent.start_identity.is_none() {
        bail!("parent start identity is required on this platform");
    }
    Ok(())
}

View on GitHub (pinned to affd8760f4)

Solutions

  1. Populate parent.pid with the actual PID of the supervising application before calling validate_launch
  2. Never hard-code 0 or 1 as the parent PID; fail fast upstream if the parent is unknown
  3. Ensure the launch request originates from the host app, not from the service process itself
  4. Add an assertion/logging when pid is unset so misconfiguration surfaces early

Example fix

// before
let parent = StorageProviderParentLifetimeV1 { pid: 0, .. };
// after
let parent = StorageProviderParentLifetimeV1 { pid: std::process::id(), token: token, .. }; // real host pid, not 0/1/self
Defensive patterns

Strategy: validation

Validate before calling

fn parent_pid_ok(pid: u32) -> bool { pid > 1 && pid != std::process::id() }

Prevention

When it happens

Trigger: validate_launch_parent is given StorageProviderParentLifetimeV1 with pid <= 1 or pid == std::process::id() — e.g. a caller passing pid 0/1 as 'system', or accidentally passing the service's own pid.

Common situations: Config defaulting parent pid to 0/1 when the real parent is unknown; test harnesses reusing dummy pids; a launch request crafted by the service itself rather than its host app.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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