sxyazi/yazi · error · anyhow::Error

empty kind

Error message

empty kind

What it means

Payload::from_str parses a DDS inter-process wire line of the shape `kind,receiver,sender,body` using splitn(4, ','). The first field is the ember kind (hi, hey, cd, hover, custom, ...) later interpreted by Ember::from_str. "empty kind" is the front-of-line guard: the parser found no first component to use as the message kind.

Source

Thrown at yazi-dds/src/payload.rs:62

	pub(super) fn with_sender(mut self, sender: Id) -> Self {
		self.sender = sender;
		self
	}
}

impl Payload<'static> {
	pub(super) fn emit(self) {
		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<'_> {

View on GitHub (pinned to 94abcfa92f)

Solutions

  1. Emit well-formed lines: `<kind>,<receiver u64>,<sender u64>,<json body>`, e.g. `hover,0,123,{...}`
  2. Use a real payload as the template: Display for Payload (or `ya pub` output) prints the canonical shape
  3. Remember the body keeps everything after the third comma (splitn(4)), so commas inside JSON are safe

Example fix

// before
let p = Payload::from_str("")?; // no kind field

// after
let p = Payload::from_str("hi,0,123,{}")?;
Defensive patterns

Strategy: validation

Validate before calling

// Validate a line before parsing:
let mut parts = line.splitn(4, ',');
ensure!(!parts.next().unwrap_or_default().is_empty(), "empty kind");

Type guard

fn is_payload_line(s: &str) -> bool {
    let mut p = s.splitn(4, ',');
    !p.next().unwrap_or_default().is_empty()
        && p.next().map(|x| x.parse::<u64>().is_ok()).unwrap_or(false)
        && p.next().map(|x| x.parse::<u64>().is_ok()).unwrap_or(false)
        && p.next().is_some()
}

Prevention

When it happens

Trigger: Feeding Payload::from_str a structurally malformed DDS line — empty input or a line whose leading field is absent — so splitn yields nothing usable for the kind slot. In practice it is the defensive first error a broken line can hit before the receiver/sender/body checks.

Common situations: Hand-testing ya pub output parsing; piping truncated or garbage lines into a DDS consumer; protocol/format mismatch between a yazi version and an external tool writing payload lines.

Related errors


AI-assisted analysis of sxyazi/yazi@94abcfa92f (2026-08-16). Data as JSON: /api/errors/e528c46f702cd45f. Report an issue: GitHub.