astrid-runtime/astrid · error
invalid parent token
Error message
invalid parent token
What it means
validate_launch_parent also validates the parent's lifetime token: it must be 16–512 bytes and contain no control characters. The token identifies the parent's lifetime for supervision; an empty, oversized, or control-character-laden token is treated as malformed and rejected.
Source
Thrown at crates/astrid-storage-provider-fskit/src/service.rs:405
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(())
}
#[cfg(test)]
mod tests {
use super::*;
#[cfg(target_os = "macos")]View on GitHub (pinned to affd8760f4)
Solutions
- Generate a token of 16–512 printable characters (e.g. 32-char random hex/base64)
- Trim/strip control characters and newlines from the token before sending
- Check where the token is produced and ensure it isn't truncated or left as a default empty string
- Validate the token length client-side before constructing the launch request
Example fix
// before
let token = format!("{}\n", raw_bytes); // control chars, maybe <16 bytes
// after
let token = base64::encode(rand::random::<[u8; 32]>()); // 44 printable chars Defensive patterns
Strategy: validation
Validate before calling
fn parent_token_ok(t: &str) -> bool { (16..=512).contains(&t.len()) && !t.chars().any(char::is_control) } Prevention
- Generate tokens as 16–512 printable chars (e.g. 32-byte hex/base64)
- Trim whitespace/newlines from tokens
- Never ship empty or placeholder tokens in config or tests
- Validate tokens at construction time
When it happens
Trigger: validate_launch_parent receives StorageProviderParentLifetimeV1 whose token is shorter than 16 bytes, longer than 512 bytes, or contains control characters (e.g. embedded \0 or \n) — typically a truncated, placeholder, or raw-binary token.
Common situations: Passing an empty/placeholder token in tests or config; generating the token as raw bytes instead of a hex/base64 string; copying a token with a trailing newline.
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
- invalid FUSE service parent token
- invalid FUSE callback token
- durable capsule {id} has unsafe WIT metadata path {relative}
- git history path must be a relative in-repository path
- FSKit lease callback token is invalid
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/8e7a1e163d292325.
Report an issue: GitHub.