{"record":{"id":"5e94f45b36775823","repo":"gitbutlerapp/gitbutler","slug":"pre-push-hook-failed","errorCode":null,"errorMessage":"pre-push hook failed: {}","messagePattern":"pre-push hook failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/legacy/push.rs","lineNumber":101,"sourceCode":"                })?;\n        let before_sha = remote_before_sha(repo, remote_refname.as_ref())?;\n        let remote = repo.find_remote(remote_name.as_str())?;\n        let remote_url = remote\n            .url(gix::remote::Direction::Push)\n            .or_else(|| remote.url(gix::remote::Direction::Fetch))\n            .with_context(|| format!(\"Remote named {remote_name} didn't have a URL\"))?;\n\n        if run_hooks {\n            match hooks::pre_push(\n                repo,\n                &remote_name,\n                &remote_url.to_bstring().to_str_lossy(),\n                local_sha.id,\n                &RemoteRefname::from_str(&remote_refname.as_bstr().to_str_lossy())?,\n                run_husky_hooks,\n            )? {\n                hooks::HookResult::Success | hooks::HookResult::NotConfigured => Ok(()),\n                hooks::HookResult::Failure(error_data) => Err(anyhow::anyhow!(\n                    \"pre-push hook failed: {}\",\n                    error_data.error\n                )),\n            }?;\n        }\n\n        let gerrit_push_args = gerrit_push_args(\n            gerrit_mode,\n            local_sha.id,\n            target_branch_name.as_bstr(),\n            &push_opts,\n        );\n        let push_output = push_with_askpass(\n            repo,\n            local_sha.id,\n            remote_refname.as_ref(),\n            with_force,\n            force_push_protection && !skip_force_push_protection,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/legacy/push.rs#L83-L119","documentation":"Raised in `workspace_branch_and_ancestors_push` (crates/but-workspace/src/legacy/push.rs:101) when a configured pre-push hook (e.g. a Husky hook) exits with failure during a push. The hook's stderr/error text is embedded in the message via `error_data.error`.","triggerScenarios":"Pushing workspace branches with `run_husky_hooks` enabled while the repository has a pre-push hook (`.husky/pre-push` or git hooks path) that returns a non-zero exit code.","commonSituations":"Lint/test gates in the pre-push hook failing; hook scripts broken after Node dependency changes; hook failing only on CI-related checks; user pushed with hooks enabled but local state doesn't pass the checks.","solutions":["Read the embedded hook error output and fix whatever the hook is failing on (lint, tests, etc.)","Run the hook command manually (`git push --dry-run` or invoke `.husky/pre-push`) to reproduce","Temporarily bypass with `git push --no-verify` or by disabling husky hooks in the API call if appropriate","Repair or reinstall husky (`npx husky install`) if the hook itself is broken"],"exampleFix":"// before\npush::workspace_branch_and_ancestors_push(..., run_husky_hooks=true)?;\n// after\n// fix failing pre-push hook, or opt out:\npush::workspace_branch_and_ancestors_push(..., run_husky_hooks=false)?;","handlingStrategy":"try-catch","validationCode":"// dry-run push to exercise hooks without updating the remote\nlet status = std::process::Command::new(\"git\")\n    .args([\"push\", \"--dry-run\", remote, refspec])\n    .status()?;","typeGuard":null,"tryCatchPattern":"match push::workspace_branch_and_ancestors_push(..., run_husky_hooks) {\n    Err(e) if e.to_string().starts_with(\"pre-push hook failed\") => report_hook_output(&e),\n    other => other?,\n}","preventionTips":["Run lint/test suites before pushing so hook gates pass","Keep husky installed and hook scripts executable","Use --no-verify only deliberately, never as a default"],"tags":["git","hooks","push"],"backgroundTag":"git-hook-failed","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}