Hmbown/CodeWhale · error

message should deserialize

Error message

message should deserialize

What it means

A test-only expect("message should deserialize") panic: serde_json failed to parse the just-serialized JSON back into a Message. The test guards that an InterruptedAssistant message round-trips as a distinct session item; failure means the serialized form (role tag or content shape) is not accepted on the way back, so interrupted turns would be lost or coerced on reload.

Solutions

  1. Diff the serialized JSON against what Deserialize expects for Role::InterruptedAssistant
  2. Align the serde attributes (tag, rename, content) so the serialized form parses back
  3. Cover the full content-block set in the round-trip test to catch asymmetry early
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

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

        };
        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");
    }

    #[test]
    fn unrecognized_deepseek_models_do_not_inherit_sibling_metadata() {
        for model in [
            "deepseek-v4-flash-20260423",
            "deepseek-v4-pro-20260423",
            "deepseek-coder",
            "deepseek-v3.2-0324",
            "deepseek-v4.1-flash-expires-on-0910",
        ] {
            assert_eq!(context_window_for_model(model), None, "{model}");
        }
        assert!(!model_supports_reasoning(
            "deepseek-v4.1-flash-expires-on-0910"
        ));

View on GitHub (pinned to 433685b202)