{"record":{"id":"fe24750e16df1d02","repo":"nikivdev/code","slug":"commit-not-found","errorCode":null,"errorMessage":"commit not found: {}","messagePattern":"commit not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commits.rs","lineNumber":480,"sourceCode":"    Ok(Some(CommitEntry {\n        hash,\n        full_hash,\n        subject,\n        relative_time,\n        author,\n        has_ai_metadata,\n        is_top: true,\n        display,\n    }))\n}\n\nfn resolve_full_hash(commit_ref: &str) -> Result<String> {\n    let output = Command::new(\"git\")\n        .args([\"rev-parse\", commit_ref])\n        .output()\n        .context(\"failed to run git rev-parse\")?;\n    if !output.status.success() {\n        bail!(\"commit not found: {}\", commit_ref);\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())\n}\n\nfn load_top_entries() -> Result<Vec<TopEntry>> {\n    let path = top_file_path()?;\n    if !path.exists() {\n        return Ok(Vec::new());\n    }\n    let content = fs::read_to_string(&path).context(\"failed to read top commits\")?;\n    let mut entries = Vec::new();\n    for line in content.lines() {\n        let trimmed = line.trim();\n        if trimmed.is_empty() {\n            continue;\n        }\n        let (hash, label) = match trimmed.split_once('\\t') {\n            Some((hash, label)) => (hash.to_string(), Some(label.to_string())),","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commits.rs#L462-L498","documentation":"Thrown by `resolve_full_hash` when `git rev-parse <commit_ref>` exits non-zero, i.e. git cannot resolve the given reference to a commit. Used by `unmark_top_commit`, so it typically means a stored 'top' entry references a commit that no longer exists or was never valid.","triggerScenarios":"Calling unmark_top_commit with a commit ref that is misspelled, was garbage-collected, belongs to a pruned branch, or is an abbreviated hash whose object no longer exists.","commonSituations":"Commit removed by `git rebase`/`reset`/`filter-branch` after being marked, stale top-file entries after cloning a fresh repo, typo'd short hash, or ref names differing between local and remote.","solutions":["Run `git rev-parse <ref>` manually to confirm the ref is invalid","Look up the intended commit via `git log --oneline` or `git reflog` and use its current hash","Remove or fix the stale entry in the top file so unmark no longer references it","If the commit was rebased away, find its equivalent in the new history (git log --all --grep)"],"exampleFix":"// before\nunmark_top_commit(\"a1b2c3d\") // commit not found: a1b2c3d\n// after\nlet valid = String::from_utf8_lossy(\n    &Command::new(\"git\").args([\"rev-parse\", \"--verify\", \"a1b2c3d^{commit}\"],).output()?.stdout,\n);\nif valid.trim().is_empty() { eprintln!(\"ref not found, skipping unmark\"); return Ok(()); }","handlingStrategy":"validation","validationCode":"// verify the ref resolves before unmarking\nlet ok = Command::new(\"git\")\n    .args([\"rev-parse\", \"--verify\", \"--quiet\", &format!(\"{}^{{commit}}\", commit_ref)])\n    .output()?\n    .status.success();\nif !ok {\n    eprintln!(\"{commit_ref} no longer exists; cleaning stale entry\");\n    return Ok(());\n}","typeGuard":"fn commit_exists(commit_ref: &str) -> bool {\n    Command::new(\"git\")\n        .args([\"rev-parse\", \"--verify\", \"--quiet\", &format!(\"{}^{{commit}}\", commit_ref)])\n        .output()\n        .map(|o| o.status.success())\n        .unwrap_or(false)\n}","tryCatchPattern":"match unmark_top_commit(commit_ref) {\n    Err(e) if e.to_string().starts_with(\"commit not found\") => {\n        eprintln!(\"{commit_ref} is gone (rebase/reset?); removing stale top entry\");\n        remove_stale_top_entry(commit_ref)?;\n    }\n    other => other?,\n}","preventionTips":["Resolve refs to full hashes at mark time and re-check before unmark","Prune stale entries after rebases/resets","Use `git rev-parse --verify` as a pre-check for any user-supplied ref","Consult `git reflog` to recover hashes after history rewrites"],"tags":["git","reference","lookup"],"backgroundTag":"git-ref-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}