{"record":{"id":"ff09cf007979438a","repo":"GitoxideLabs/gitoxide","slug":"could-not-read-review-reference-err","errorCode":null,"errorMessage":"could not read review reference: {err}","messagePattern":"could not read review reference: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/undo.rs","lineNumber":164,"sourceCode":"            return Ok(true);\n        }\n        let Some(parent) = stored.parent else {\n            return Ok(false);\n        };\n        id = parent;\n    }\n}\n\npub(crate) fn review_blocks_undo(repo: &gix::Repository) -> Result<bool> {\n    let references = repo.references().context(\"could not open review references\")?;\n    for reference in references\n        .prefixed(crate::history::REVIEW_PREFIX.as_bstr())\n        .context(\"could not iterate review references\")?\n    {\n        let reference = match reference {\n            Ok(reference) => reference,\n            Err(err) if crate::history::is_missing_ref(&*err) => continue,\n            Err(err) => return Err(anyhow::anyhow!(\"could not read review reference: {err}\")),\n        };\n        if crate::history::review_number(reference.name().as_bstr()).is_some() {\n            return Ok(true);\n        }\n    }\n    Ok(false)\n}\n\npub(crate) fn clear(repo: &gix::Repository) -> Result<()> {\n    let mut edits = Vec::new();\n    for name in [TIP_REF, CURSOR_REF] {\n        let Some(reference) = repo\n            .try_find_reference(name)\n            .with_context(|| format!(\"could not read {name}\"))?\n        else {\n            continue;\n        };\n        edits.push(RefEdit::delete(","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/undo.rs#L146-L182","documentation":"While iterating review references (refs under the review prefix), one reference could not be read from storage. Missing refs are silently skipped via `is_missing_ref`, but any other read failure aborts the `review_blocks_undo` check with this wrapped error. It means the ref storage itself is unhealthy, not that a ref is absent.","triggerScenarios":"Calling `record`, `position`, `plan_undo`, `plan_redo` (via `review_blocks_undo`) when a ref exists under the review prefix but reference iteration yields an `Err` other than a missing-ref (e.g. corrupt packed-refs entry, I/O error reading the ref file).","commonSituations":"Corrupted `.git/refs` or `packed-refs` entries; filesystem permission or I/O problems; partially written refs after a crash; worktree with unreadable git dir.","solutions":["Inspect the review refs manually (e.g. `git for-each-ref` under the review prefix) to find the unreadable ref.","Fix repository storage: repair or delete the corrupt ref file / rebuild packed-refs.","Check filesystem permissions and disk health for the git directory.","If the ref is genuinely gone, ensure the error truly maps to a missing ref so it would be skipped."],"exampleFix":"// before: abort on any ref read error\nErr(err) => return Err(anyhow::anyhow!(\"could not read review reference: {err}\")),\n// after: keep the missing-ref skip and repair the repository before retrying\nErr(err) if crate::history::is_missing_ref(&*err) => continue,\nErr(err) => return Err(anyhow::anyhow!(\"could not read review reference: {err}\")),","handlingStrategy":"try-catch","validationCode":"// pre-check repository ref storage health\nrepo.references()?.prefixed(crate::history::REVIEW_PREFIX.as_bstr())\n    .map(|r| r.map(|_| ()))\n    .collect::<Result<Vec<_>, _>>()?;","typeGuard":null,"tryCatchPattern":"match repo.undo_check() {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"could not read review reference\") => repair_refs_then_retry(),\n    Err(e) => return Err(e),\n}","preventionTips":["Run `git fsck` periodically on repositories using the undo queue.","Avoid editing files under .git/refs by hand.","Check disk/filesystem health on the machine hosting the repo."],"tags":["git","references","repository-corruption","iteration"],"backgroundTag":"git-command-failed","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}