{"record":{"id":"e528c46f702cd45f","repo":"sxyazi/yazi","slug":"empty-kind","errorCode":null,"errorMessage":"empty kind","messagePattern":"empty kind","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"yazi-dds/src/payload.rs","lineNumber":62,"sourceCode":"\tpub(super) fn with_sender(mut self, sender: Id) -> Self {\n\t\tself.sender = sender;\n\t\tself\n\t}\n}\n\nimpl Payload<'static> {\n\tpub(super) fn emit(self) {\n\t\temit!(Call(relay!(app:accept_payload).with_any(\"payload\", self)));\n\t}\n}\n\nimpl FromStr for Payload<'static> {\n\ttype Err = anyhow::Error;\n\n\tfn from_str(s: &str) -> Result<Self, Self::Err> {\n\t\tlet mut parts = s.splitn(4, ',');\n\n\t\tlet kind = parts.next().ok_or_else(|| anyhow!(\"empty kind\"))?;\n\n\t\tlet receiver =\n\t\t\tparts.next().and_then(|s| s.parse().ok()).ok_or_else(|| anyhow!(\"invalid receiver\"))?;\n\n\t\tlet sender =\n\t\t\tparts.next().and_then(|s| s.parse().ok()).ok_or_else(|| anyhow!(\"invalid sender\"))?;\n\n\t\tlet body = parts.next().ok_or_else(|| anyhow!(\"empty body\"))?;\n\n\t\tOk(Self { receiver, sender, body: Ember::from_str(kind, body)? })\n\t}\n}\n\nimpl<'a> From<Ember<'a>> for Payload<'a> {\n\tfn from(value: Ember<'a>) -> Self { Self::new(value) }\n}\n\nimpl TryFrom<ActionCow> for Payload<'_> {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/sxyazi/yazi/blob/94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2/yazi-dds/src/payload.rs#L44-L80","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Emit well-formed lines: `<kind>,<receiver u64>,<sender u64>,<json body>`, e.g. `hover,0,123,{...}`","Use a real payload as the template: Display for Payload (or `ya pub` output) prints the canonical shape","Remember the body keeps everything after the third comma (splitn(4)), so commas inside JSON are safe"],"exampleFix":"// before\nlet p = Payload::from_str(\"\")?; // no kind field\n\n// after\nlet p = Payload::from_str(\"hi,0,123,{}\")?;","handlingStrategy":"validation","validationCode":"// Validate a line before parsing:\nlet mut parts = line.splitn(4, ',');\nensure!(!parts.next().unwrap_or_default().is_empty(), \"empty kind\");","typeGuard":"fn is_payload_line(s: &str) -> bool {\n    let mut p = s.splitn(4, ',');\n    !p.next().unwrap_or_default().is_empty()\n        && p.next().map(|x| x.parse::<u64>().is_ok()).unwrap_or(false)\n        && p.next().map(|x| x.parse::<u64>().is_ok()).unwrap_or(false)\n        && p.next().is_some()\n}","tryCatchPattern":null,"preventionTips":["Memorize the wire shape: kind,receiver,sender,body with decimal u64 ids","Use Payload's Display output as the canonical template","Validate external lines with is_payload_line before from_str"],"tags":["dds","pubsub","parsing","protocol"],"backgroundTag":null,"analyzedSha":"94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2","analyzedAt":"2026-08-16T09:56:24.836Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}