sxyazi/yazi · error · anyhow::Error
empty body
Error message
empty body
What it means
The fourth component of a DDS payload line (everything after the third comma) is the JSON body handed to Ember::from_str(kind, body). "empty body" means splitn(4, ',') produced no fourth component — the line has fewer than three commas, so there is no body to parse. A trailing comma is a different failure: it yields an empty string that passes here and fails inside Ember::from_str.
Source
Thrown at yazi-dds/src/payload.rs:70
emit!(Call(relay!(app:accept_payload).with_any("payload", self)));
}
}
impl FromStr for Payload<'static> {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut parts = s.splitn(4, ',');
let kind = parts.next().ok_or_else(|| anyhow!("empty kind"))?;
let receiver =
parts.next().and_then(|s| s.parse().ok()).ok_or_else(|| anyhow!("invalid receiver"))?;
let sender =
parts.next().and_then(|s| s.parse().ok()).ok_or_else(|| anyhow!("invalid sender"))?;
let body = parts.next().ok_or_else(|| anyhow!("empty body"))?;
Ok(Self { receiver, sender, body: Ember::from_str(kind, body)? })
}
}
impl<'a> From<Ember<'a>> for Payload<'a> {
fn from(value: Ember<'a>) -> Self { Self::new(value) }
}
impl TryFrom<ActionCow> for Payload<'_> {
type Error = anyhow::Error;
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
a.take_any2("payload").ok_or_else(|| anyhow!("Missing 'payload' in Payload"))?
}
}
impl Display for Payload<'_> {View on GitHub (pinned to 94abcfa92f)
Solutions
- Append the JSON body: `hover,0,123,{}`
- Make sure the transport preserves whole lines (JSON bodies must stay on one line)
- Reject lines with fewer than 4 split components before calling from_str
Example fix
// before
Payload::from_str("hi,0,1")?; // no body
// after
Payload::from_str("hi,0,1,{}")?; Defensive patterns
Strategy: validation
Validate before calling
// Require a body component before parsing: ensure!(line.splitn(4, ',').nth(3).is_some(), "empty body"); let p = Payload::from_str(line)?;
Prevention
- Always append the JSON body as the fourth component
- Keep DDS lines intact — JSON bodies must stay on one line
- Reject lines with fewer than 4 split components up front
When it happens
Trigger: Lines like `hover,0,123` (three fields, body never arrived) or any input truncated before the body section — e.g. a line-based transport splitting long JSON bodies at an embedded newline.
Common situations: Truncated output from `ya pub` or a remote peer; hand-typed test messages without the JSON part; log scrapers losing the tail of long lines.
Related errors
AI-assisted analysis of sxyazi/yazi@94abcfa92f (2026-08-16).
Data as JSON: /api/errors/46e2ac7a54fb0477.
Report an issue: GitHub.