Hmbown/CodeWhale · error

serialize core path

Error message

serialize core path

What it means

A test-only expect("serialize core path") panic: serde_json::to_vec failed on the MessageRequest obtained through the codewhale_core::request path. Since the test asserts the TUI and core values serialize to equal bytes, this panic means the core-typed clone itself failed to serialize, indicating a real incompatibility between the two type paths rather than a test-fixture issue.

Solutions

  1. Compare the Serialize impls of the TUI and core MessageRequest types for divergence
  2. Fix whichever type's serialization errors, keeping the wire format identical across both paths
  3. Add a regression test covering the offending field on both paths
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/models/src/lib.rs:911 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/c650256de1130a3a. Report an issue: GitHub.

Appendix: source

Thrown at crates/models/src/lib.rs:911

        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)