{"record":{"id":"0934b77f618939c7","repo":"nikivdev/code","slug":"jj-bookmark-set-failed","errorCode":null,"errorMessage":"jj bookmark set failed: {}","messagePattern":"jj bookmark set failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":8634,"sourceCode":"        // Ensure bookmark points at the commit, then push it.\n        // If jj is unhealthy (store/index/template issues), fall back to git push.\n        let jj_result = (|| -> Result<()> {\n            let set_output = Command::new(\"jj\")\n                .current_dir(repo_root)\n                .args([\n                    \"bookmark\",\n                    \"set\",\n                    head,\n                    \"-r\",\n                    commit_sha,\n                    \"--allow-backwards\",\n                ])\n                .output()\n                .context(\"failed to run jj bookmark set for PR head\")?;\n            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                );","sourceCodeStart":8616,"sourceCodeEnd":8652,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L8616-L8652","documentation":"Raised when the explicit `jj bookmark set <head>` command used to move the PR-head bookmark exits non-zero. The tool wraps both trimmed stderr and stdout into the message so the jj diagnostic is preserved. This is a dedicated, more specific wrapper than the generic `jj {} failed` for the PR-head bookmark step.","triggerScenarios":"During PR-head setup, `Command::new(jj).args([\"bookmark\", \"set\", ...])` returns a failing status — e.g. the target revision is unresolvable, the bookmark name is invalid/conflicting, or the workspace is stale.","commonSituations":"Bookmark name colliding with an existing bookmark on another commit without conflict resolution flags; invalid characters in generated bookmark names; jj workspace out of date; wrong revision id passed by an upstream bug.","solutions":["Read the combined stderr/stdout after 'jj bookmark set failed:'","Run `jj bookmark set <name> -r <rev>` manually to see the full error","Check the bookmark name for invalid characters or conflicts (`jj bookmark list`)","Update the workspace (`jj st`) and retry the operation"],"exampleFix":"// before\nError: jj bookmark set failed: Error: Failed to set bookmark\n// after\n$ jj st                       # sync working copy\n$ jj bookmark list            # inspect conflicts\n$ tool create-review          # retry","handlingStrategy":"try-catch","validationCode":"let st = Command::new(\"jj\").args([\"st\"]).output()?;\nif !st.status.success() {\n    return Err(anyhow!(\"jj workspace stale; run `jj st` before bookmark ops\"));\n}\n// validate bookmark name charset up-front\nif !head.chars().all(|c| c.is_ascii_alphanumeric() || \"-_/\".contains(c)) {\n    return Err(anyhow!(\"invalid bookmark name: {head}\"));\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = result {\n    let msg = e.to_string();\n    if msg.contains(\"bookmark set failed\") {\n        eprintln!(\"inspect `jj bookmark list` for conflicts; retry after `jj st`\");\n    }\n    return Err(e);\n}","preventionTips":["Sync the working copy (`jj st`) before bookmark operations","Use deterministic, charset-safe bookmark names (e.g. review/pr-<num>)","Check `jj bookmark list` for pre-existing conflicting bookmarks","Re-run failing `jj bookmark set` manually to see full diagnostics"],"tags":["vcs","jj","bookmark","process-exit"],"backgroundTag":"cli-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}