{"record":{"id":"b1e38fd25133adef","repo":"nikivdev/code","slug":"jj-workspace-corrupted","errorCode":null,"errorMessage":"jj workspace corrupted","messagePattern":"jj workspace corrupted","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":8421,"sourceCode":"        index += 1;\n        if index > 50 {\n            bail!(\"too many review bookmarks with base {}\", base);\n        }\n    }\n\n    if let Err(err) = jj_run_in(&jj_root, &[\"bookmark\", \"create\", &name, \"-r\", commit_sha]) {\n        let msg = err.to_string().to_lowercase();\n        if msg.contains(\"commit not found\")\n            || msg.contains(\"current working-copy commit not found\")\n            || msg.contains(\"failed to load short-prefixes index\")\n            || msg.contains(\"unexpected error from store\")\n            || msg.contains(\"failed to check out a commit\")\n        {\n            println!(\"⚠️  jj workspace appears corrupted; skipping review bookmark creation.\");\n            println!(\n                \"   Fix: `jj git import` (or if still broken: `rm -rf .jj && jj git init --colocate`)\"\n            );\n            bail!(\"jj workspace corrupted\");\n        }\n        return Err(err);\n    }\n    println!(\"Queued review bookmark {}\", name);\n    Ok(name)\n}\n\nfn delete_review_bookmark(repo_root: &Path, bookmark: &str) {\n    if let Some(jj_root) = vcs::jj_root_if_exists(repo_root) {\n        let _ = jj_run_in(&jj_root, &[\"bookmark\", \"delete\", bookmark]);\n    }\n}\n\nfn jj_bookmark_exists(repo_root: &Path, name: &str) -> bool {\n    let output = jj_capture_in(repo_root, &[\"bookmark\", \"list\"]).unwrap_or_default();\n    for line in output.lines() {\n        let trimmed = line.trim_start().trim_start_matches('*').trim();\n        let Some((token, _rest)) = trimmed.split_once(' ') else {","sourceCodeStart":8403,"sourceCodeEnd":8439,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L8403-L8439","documentation":"This error is raised when the tool detects that the jj (Juujutsu VCS) workspace is in a state that prevents it from creating a review bookmark. It is thrown after a jj command fails with messages indicating a failed checkout or inconsistent workspace (e.g. after `jj workspace`/checkout operations fail). The library bails out early and prints remediation hints instead of continuing with a broken workspace.","triggerScenarios":"Running the review-bookmark creation flow when a preceding jj command's stderr/stdout contains 'failed to check out a commit' (or a similar corruption-indicating message), so the function prints the corruption warning and calls bail!(\"jj workspace corrupted\").","commonSituations":"A `.jj` directory that was created by a different jj version or partially initialized; a workspace where `jj git init` was never run with --colocate in a git repo; interrupted jj operations leaving stale lockfiles/checkouts; importing a git repo whose refs jj cannot map.","solutions":["Run `jj git import` to re-sync jj with the underlying git refs","If import does not fix it, reinitialize the colocated workspace: `rm -rf .jj && jj git init --colocate`","Verify jj version compatibility with the repo format and re-run the command","Restore the workspace from a clean clone if corruption persists"],"exampleFix":"// before (broken workspace)\n$ tool create-review\n⚠️  jj workspace appears corrupted; skipping review bookmark creation.\nError: jj workspace corrupted\n// after\n$ jj git import\n$ tool create-review\nQueued review bookmark review/pr-123","handlingStrategy":"try-catch","validationCode":"// Run before invoking the review flow\nlet out = Command::new(\"jj\").args([\"st\"]).output()?;\nif !out.status.success() {\n    eprintln!(\"jj workspace unhealthy; run `jj git import` first\");\n    return Ok(()); // skip review flow\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"jj workspace corrupted\") => {\n        // user ran `rm -rf .jj && jj git init --colocate`? recover and retry once\n        run(\"jj git import\")?;\n        retry_operation()\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Always initialize repos with `jj git init --colocate` so git and jj share refs","Run `jj git import` after external git operations (fetch, reset, rebase)","Avoid killing jj mid-operation; check for stale `.jj` lockfiles","Pin a known-good jj version compatible with your repos"],"tags":["vcs","jj","corruption","workspace"],"backgroundTag":"jj-workspace-corrupted","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}