nikivdev/code · error

kimi review failed: {}

Error message

kimi review failed: {}

What it means

Thrown when the kimi CLI subprocess exits with a non-success status. The library picks stderr (or stdout if stderr is empty) as the reason and embeds it in the message, so kimi's own error text is the payload of this error.

Source

Thrown at src/commit.rs:6059

        }
        let _ = stderr_tx.send(collected);
    });

    let status = child.wait().context("failed to wait for kimi")?;
    let _ = stdout_handle.join();
    let _ = stderr_handle.join();

    let stdout_bytes = stdout_rx.recv().unwrap_or_default();
    let stderr_text = stderr_rx.recv().unwrap_or_default();

    if !status.success() {
        let stdout_text = String::from_utf8_lossy(&stdout_bytes);
        let error_msg = if stderr_text.trim().is_empty() {
            stdout_text.trim()
        } else {
            stderr_text.trim()
        };
        bail!("kimi review failed: {}", error_msg);
    }

    let stdout_text = String::from_utf8_lossy(&stdout_bytes).trim().to_string();
    if stdout_text.is_empty() {
        bail!("kimi returned empty output");
    }

    // Parse the stream-json output from kimi
    // Format: {"role":"assistant","content":[{"type":"think","think":"..."},{"type":"text","text":"..."}]}
    let result = extract_kimi_text_content(&stdout_text).unwrap_or_else(|| stdout_text.clone());
    if result.is_empty() {
        bail!("kimi returned empty review output (no text content in response)");
    }

    // Try to parse JSON from output
    let mut review_json = parse_review_json(&result);
    let future_tasks = review_json
        .as_ref()

View on GitHub (pinned to a747e741ae)

Solutions

  1. Read the embedded message for kimi's actual error text and act on it.
  2. Verify kimi is installed and on PATH (`which kimi`, check version).
  3. Re-authenticate kimi / set the API key env variable.
  4. Check quota and billing on the Kimi account.
  5. Retry; transient API failures often resolve.
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: kimi installed and key set
if which::which("kimi").is_err() { anyhow::bail!("kimi CLI not on PATH"); }
if std::env::var("KIMI_API_KEY").is_err() { anyhow::bail!("KIMI_API_KEY not set"); }

Try / catch

match run_kimi_review(&diff).await {
    Ok(r) => r,
    Err(e) if e.to_string().starts_with("kimi review failed:") => {
        let reason = e.to_string().trim_start_matches("kimi review failed:");
        eprintln!("kimi error: {reason}");
        fallback_review()
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: kimi process returns non-zero exit; e.g. kimi CLI not installed, API key invalid, quota exceeded, or model/CLI error during review.

Common situations: kimi not on PATH or wrong version; missing/expired KIMI API key; quota/billing limits; network failure to Kimi's API; unsupported flags passed by the integration.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/e6a169695f7b510c. Report an issue: GitHub.