{"record":{"id":"2a1a2a4b6c42b334","repo":"Hmbown/CodeWhale","slug":"sub-agent-transcript-record-is-missing-its-message","errorCode":null,"errorMessage":"sub-agent transcript record is missing its message","messagePattern":"sub-agent transcript record is missing its message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":7621,"sourceCode":"        if record.get(\"kind\").and_then(Value::as_str) != Some(\"message\") {\n            return Err(anyhow!(\"unknown sub-agent transcript artifact record\"));\n        }\n        let index = record\n            .get(\"index\")\n            .and_then(Value::as_u64)\n            .and_then(|value| usize::try_from(value).ok())\n            .ok_or_else(|| anyhow!(\"sub-agent transcript message is missing its index\"))?;\n        if index != messages.len() {\n            return Err(anyhow!(\n                \"sub-agent transcript message index {index} does not follow {}\",\n                messages.len()\n            ));\n        }\n        let message = serde_json::from_value::<Message>(\n            record\n                .get(\"message\")\n                .cloned()\n                .ok_or_else(|| anyhow!(\"sub-agent transcript record is missing its message\"))?,\n        )?;\n        messages.push(message);\n    }\n    Ok(messages)\n}\n\nfn remove_subagent_transcript_artifact(state_root: &Path, agent_id: &str) -> Result<bool> {\n    let state_root = normalize_subagent_workspace(state_root);\n    let path = checked_subagent_transcript_artifact_path(&state_root, agent_id)?;\n    reject_root_relative_symlinks(&state_root, &path)?;\n    let metadata = match fs::symlink_metadata(&path) {\n        Ok(metadata) => metadata,\n        Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(false),\n        Err(err) => return Err(err.into()),\n    };\n    if metadata.file_type().is_symlink() || !metadata.file_type().is_file() {\n        return Err(anyhow!(\n            \"sub-agent transcript artifact is not a regular file: {}\",","sourceCodeStart":7603,"sourceCodeEnd":7639,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tools/subagent/mod.rs#L7603-L7639","documentation":"A message record passed the kind and index checks but has no \"message\" field to deserialize. The loader clones that field into a Message value; a record without the payload cannot be turned into a message and the load aborts.","triggerScenarios":"Records written with kind and index only (partial write, crash between field writes, or an external writer emitting a stub record).","commonSituations":"Interrupted writes leaving truncated JSON objects; hand-crafted records; a writer bug that serializes metadata without the message payload.","solutions":["Remove or complete the stub record so every message line embeds the full message object.","Regenerate the artifact via re-run rather than editing partial lines by hand.","If a writer bug produced it, fix that writer to emit the whole record atomically (one JSON line per record)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for line in raw.lines().skip(1) {\n    let v: serde_json::Value = serde_json::from_str(line)?;\n    if v.get(\"message\").is_none() { /* stub record without payload: complete or drop it */ }\n}","typeGuard":"fn record_has_message(v: &serde_json::Value) -> bool {\n    v.get(\"message\").is_some()\n}","tryCatchPattern":"match load_subagent_transcript_artifact(&state_root, agent_id) {\n    Err(e) if e.to_string().contains(\"missing its message\") => { /* remove stub record, renumber, or regenerate */ }\n    r => r?,\n}","preventionTips":["Write each record as one complete JSON line; avoid incremental field writes.","Validate artifacts parse fully after any interrupted run."],"tags":["subagent","transcript","missing-field","message","rust"],"backgroundTag":"missing-required-argument","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}