{"record":{"id":"46e2ac7a54fb0477","repo":"sxyazi/yazi","slug":"empty-body","errorCode":null,"errorMessage":"empty body","messagePattern":"empty body","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"yazi-dds/src/payload.rs","lineNumber":70,"sourceCode":"\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<'_> {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {\n\t\ta.take_any2(\"payload\").ok_or_else(|| anyhow!(\"Missing 'payload' in Payload\"))?\n\t}\n}\n\nimpl Display for Payload<'_> {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/sxyazi/yazi/blob/94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2/yazi-dds/src/payload.rs#L52-L88","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nPayload::from_str(\"hi,0,1\")?; // no body\n\n// after\nPayload::from_str(\"hi,0,1,{}\")?;","handlingStrategy":"validation","validationCode":"// Require a body component before parsing:\nensure!(line.splitn(4, ',').nth(3).is_some(), \"empty body\");\nlet p = Payload::from_str(line)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["dds","pubsub","parsing","truncation"],"backgroundTag":null,"analyzedSha":"94abcfa92f4ad3f0a1aef6c1ea083cfb8aa6c8c2","analyzedAt":"2026-08-16T09:56:24.836Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}