Hmbown/CodeWhale · error

serializing a Rust string cannot fail

Error message

serializing a Rust string cannot fail

What it means

render_review_argv_value() serializes a &str with serde_json and unwraps: serializing a Rust string into a JSON string is infallible (no I/O, no custom serializers). The expect documents that invariant; firing would indicate a serde_json bug or a changed serializer setup.

Source

Thrown at crates/tui/src/commands/groups/plugins/render.rs:238

                && candidate
                    .canonicalize()
                    .is_ok_and(|path| path.starts_with(&plugin.canonical_root))
            {
                return format!(
                    "#{position} plugin-path={}",
                    render_review_argv_value(argument)
                );
            }
            format!("#{position} value={}", render_review_argv_value(argument))
        })
        .collect()
}

fn render_review_argv_value(value: &str) -> String {
    // JSON string syntax is a lossless, unambiguous terminal representation:
    // whitespace, quotes, backslashes, and punctuation retain their exact
    // argv semantics without hiding arbitrary values behind redaction.
    serde_json::to_string(value).expect("serializing a Rust string cannot fail")
}

fn render_review_values(values: &[String]) -> String {
    if values.is_empty() {
        return "none".to_string();
    }
    values
        .iter()
        .map(|value| escape_review_text(value))
        .collect::<Vec<_>>()
        .join(", ")
}

fn render_mcp_timeouts(server: &crate::mcp::McpServerConfig) -> String {
    format!(
        "connect={}/execute={}/read={}",
        server
            .connect_timeout

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Confirm serde_json::to_string is still used on a plain &str
  2. If the value type changes to something fallible, propagate the error instead of expecting
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/tui/src/commands/groups/plugins/render.rs:238 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/89e6b69a5a75c001. Report an issue: GitHub.