{"record":{"id":"59599d409cd17185","repo":"nikivdev/code","slug":"jj-git-push-failed","errorCode":null,"errorMessage":"jj git push failed: {}","messagePattern":"jj git push failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":8649,"sourceCode":"            if !set_output.status.success() {\n                let stderr = String::from_utf8_lossy(&set_output.stderr);\n                let stdout = String::from_utf8_lossy(&set_output.stdout);\n                bail!(\n                    \"jj bookmark set failed: {}\",\n                    format!(\"{}\\n{}\", stderr.trim(), stdout.trim()).trim()\n                );\n            }\n\n            // We often push a brand new review/pr bookmark as the PR head.\n            let push_output = Command::new(\"jj\")\n                .current_dir(repo_root)\n                .args([\"git\", \"push\", \"--bookmark\", head, \"--allow-new\"])\n                .output()\n                .context(\"failed to run jj git push for PR head\")?;\n            if !push_output.status.success() {\n                let stderr = String::from_utf8_lossy(&push_output.stderr);\n                let stdout = String::from_utf8_lossy(&push_output.stdout);\n                bail!(\n                    \"jj git push failed: {}\",\n                    format!(\"{}\\n{}\", stderr.trim(), stdout.trim()).trim()\n                );\n            }\n\n            Ok(())\n        })();\n        if jj_result.is_ok() {\n            // jj push uses the repo's configured/default git remote.\n            // Keep plain branch head; gh can resolve this for same-repo pushes.\n            return Ok(head.to_string());\n        }\n        let jj_error = jj_result.unwrap_err().to_string();\n        let concise = jj_error\n            .lines()\n            .map(str::trim)\n            .find(|line| !line.is_empty())\n            .unwrap_or(\"jj failed\");","sourceCodeStart":8631,"sourceCodeEnd":8667,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L8631-L8667","documentation":"Raised when `jj git push --bookmark <head> --allow-new` used to publish the PR-head bookmark exits non-zero. The message embeds jj's combined trimmed stderr/stdout. Common underlying causes are remote authentication failures, rejected pushes (non-fast-forward, protected branch), or missing/invalid git remote configuration.","triggerScenarios":"During PR-head publication, `Command::new(jj).args([\"git\",\"push\",\"--bookmark\",head,\"--allow-new\"])` returns a failing status.","commonSituations":"Expired/missing credentials for the git remote (SSH key not loaded, no credential helper); remote rejecting creation of the new bookmark due to branch protection; network/VPN blocking the remote; remote URL misconfigured after repo migration.","solutions":["Read the jj push diagnostic after 'jj git push failed:'","Push manually with `jj git push --bookmark <head> --allow-new` to see full output","Fix remote auth: `ssh-add`, `gh auth login` (for HTTPS), or update credential helper","Check remote branch-protection rules that may reject new refs"],"exampleFix":"// before\nError: jj git push failed: git: Permission denied (publickey)\n// after\n$ ssh-add ~/.ssh/id_ed25519\n$ jj git push --bookmark review/pr-123 --allow-new\n$ tool create-review          # retry","handlingStrategy":"retry","validationCode":"let ls = Command::new(\"jj\").args([\"git\", \"remote\", \"list\"]).output()?;\nif !ls.status.success() || ls.stdout.is_empty() {\n    return Err(anyhow!(\"no jj git remote configured for push\"));\n}\nlet auth = Command::new(\"ssh\").args([\"-T\", \"git@github.com\"]).output();\nlet _ = auth; // best-effort credential warm-up; check ssh-agent is loaded","typeGuard":null,"tryCatchPattern":"if let Err(e) = result {\n    let msg = e.to_string();\n    if msg.contains(\"publickey\") || msg.contains(\"auth\") {\n        eprintln!(\"load SSH keys (`ssh-add`) or `gh auth login` for HTTPS\");\n    } else if msg.contains(\"rejected\") {\n        eprintln!(\"check branch protection rules blocking new refs\");\n    }\n    return Err(e);\n}","preventionTips":["Warm credentials before pushing (ssh-agent loaded, gh auth token valid)","Verify remote reachability with `git ls-remote origin` first","Confirm branch-protection allows creating the target ref name","Push manually once to validate setup before automating"],"tags":["vcs","jj","push","network","auth"],"backgroundTag":"git-push-rejected","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}