{"record":{"id":"fcf8fe016e4b1424","repo":"nikivdev/code","slug":"git-commit-failed-with","errorCode":null,"errorMessage":"git commit failed with {}","messagePattern":"git commit failed with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/codex_session_docs.rs","lineNumber":1521,"sourceCode":"        .arg(\"add\")\n        .arg(\"--\")\n        .args(paths)\n        .status()\n        .context(\"failed to run git add\")?;\n    if !status.success() {\n        bail!(\"git add failed with {}\", status);\n    }\n    Ok(())\n}\n\nfn git_commit_paths(project_root: &Path, message: &str) -> Result<()> {\n    let status = Command::new(\"git\")\n        .current_dir(project_root)\n        .args([\"commit\", \"-m\", message])\n        .status()\n        .context(\"failed to run git commit\")?;\n    if !status.success() {\n        bail!(\"git commit failed with {}\", status);\n    }\n    Ok(())\n}\n\nfn build_doc_commit_message(\n    entries: &[DocReviewQueueEntry],\n    candidate_indexes: &[usize],\n) -> String {\n    if candidate_indexes.len() == 1 {\n        let entry = &entries[candidate_indexes[0]];\n        let topic = entry\n            .changed_files\n            .first()\n            .map(|path| slugify(path, 40))\n            .filter(|value| !value.is_empty())\n            .unwrap_or_else(|| entry.session_key.clone());\n        return format!(\"docs(ai): capture codex session changes for {}\", topic);\n    }","sourceCodeStart":1503,"sourceCodeEnd":1539,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/codex_session_docs.rs#L1503-L1539","documentation":"The final `git commit -m <message>` for the documentation snapshot exited non-zero, so the library surfaces the exit status. This typically means git itself refused the commit (identity not configured, nothing staged, hooks failing, or lock contention).","triggerScenarios":"`git commit` failing in the project root during the doc commit step — missing user.name/user.email, commit hooks returning failure, nothing to commit, or GPG signing issues.","commonSituations":"Fresh CI machines without git identity configured; corporate hooks (lint/sign) rejecting auto-generated commit messages; GPG key passphrase prompts in non-interactive shells.","solutions":["Set `git config user.name` and `git config user.email` in the repo or globally","Run `git commit` manually after staging to see the actual git error","Bypass/fix failing hooks (`--no-verify`) or the signing config if appropriate"],"exampleFix":"// before\nlet status = git_commit_paths(root, msg)?;\n// after\nif !repo_has_git_identity() {\n    run_git(root, [\"config\", \"user.email\", \"docs-bot@example.com\"])?;\n    run_git(root, [\"config\", \"user.name\", \"Docs Bot\"])?;\n}\nlet status = git_commit_paths(root, msg)?;","handlingStrategy":"try-catch","validationCode":"fn has_git_identity(root: &Path) -> bool {\n    Command::new(\"git\").args([\"config\",\"user.email\"]).current_dir(root)\n        .output().map(|o| o.status.success() && !o.stdout.is_empty()).unwrap_or(false)\n}\nanyhow::ensure!(has_git_identity(root), \"configure git user.name/user.email before committing\");","typeGuard":"fn can_commit(root: &Path) -> bool {\n    has_git_identity(root) && is_usable_git_repo(root)\n}","tryCatchPattern":"match git_commit_paths(root, msg) {\n    Err(e) if e.to_string().contains(\"git commit failed\") => {\n        eprintln!(\"{} — check git identity, hooks, and signing config\", e);\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Configure user.name and user.email in CI images before running doc commits","Disable or pre-authorize hooks/GPG signing for automated commits","Stage and commit manually once to surface hook failures early"],"tags":["git","commit","subprocess"],"backgroundTag":"git-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}