Hmbown/CodeWhale · error
serialize TUI path
Error message
serialize TUI path
What it means
A test-only expect("serialize TUI path") panic: serde_json::to_vec failed on the MessageRequest built via the TUI-crate path. The test proves the historical TUI MessageRequest is the same type as codewhale_core::request::MessageRequest and serializes identically; this panic means the TUI-constructed value itself could not be serialized (bad field value), breaking that equivalence guarantee.
Solutions
- Inspect the serde error to find which MessageRequest field failed (e.g. a custom Serialize impl returning an error)
- Fix the field construction in the test or the Serialize impl in the type
- Keep both paths (TUI and core) building the identical struct so byte-equality holds
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/models/src/lib.rs:910 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/6276939de620824d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/models/src/lib.rs:910
);
let via_tui_path = MessageRequest {
model: "model".to_string(),
messages: vec![],
max_tokens: 1024,
system: None,
tools: None,
tool_choice: None,
metadata: None,
thinking: None,
reasoning_effort: None,
stream: Some(true),
temperature: None,
top_p: None,
};
let via_core_path: codewhale_core::request::MessageRequest = via_tui_path.clone();
assert_eq!(
serde_json::to_vec(&via_tui_path).expect("serialize TUI path"),
serde_json::to_vec(&via_core_path).expect("serialize core path")
);
}
#[test]
fn interrupted_assistant_role_round_trips_as_distinct_session_item() {
let message = Message {
role: Role::InterruptedAssistant,
content: vec![ContentBlock::Text {
text: "partial output".to_string(),
cache_control: None,
}],
};
let encoded = serde_json::to_string(&message).expect("message should serialize");
let decoded: Message = serde_json::from_str(&encoded).expect("message should deserialize");
assert_eq!(decoded, message);
assert_ne!(decoded.role, "assistant");
}View on GitHub (pinned to 433685b202)