nikivdev/code · error

opencode returned empty commit message

Error message

opencode returned empty commit message

What it means

Error "opencode returned empty commit message" thrown in nikivdev/code.

Source

Thrown at src/commit.rs:12721

    let stdout = String::from_utf8_lossy(&output.stdout);
    let mut message = String::new();
    for line in stdout.lines() {
        if let Ok(json) = serde_json::from_str::<serde_json::Value>(line) {
            if json.get("type").and_then(|t| t.as_str()) == Some("text") {
                if let Some(text) = json
                    .get("part")
                    .and_then(|p| p.get("text"))
                    .and_then(|t| t.as_str())
                {
                    message.push_str(text);
                }
            }
        }
    }

    let message = message.trim().to_string();
    if message.is_empty() {
        bail!("opencode returned empty commit message");
    }

    Ok(trim_quotes(&message))
}

/// Generate commit message using Claude Code CLI.
fn generate_commit_message_claude(diff: &str, status: &str, truncated: bool) -> Result<String> {
    let mut prompt = String::from(
        "Write a git commit message for these changes. Output ONLY the commit message, nothing else.\n\n\
         Guidelines:\n\
         - Use imperative mood (\"Add feature\" not \"Added feature\")\n\
         - First line: concise summary under 72 chars\n\
         - Focus on WHAT and WHY, not just listing files\n\n\
         Git diff:\n",
    );
    prompt.push_str(diff);

    if truncated {

View on GitHub (pinned to a747e741ae)

When it happens

Trigger: Thrown at src/commit.rs:12721 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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