{"record":{"id":"91f39f79335cd9c0","repo":"can1357/oh-my-pi","slug":"object-not-found-spec","errorCode":null,"errorMessage":"object not found: {spec}","messagePattern":"object not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/pi-vcs/src/error.rs","lineNumber":31,"sourceCode":"#[derive(Debug, thiserror::Error)]\npub enum Error {\n\t/// The directory is not inside a git repository / jj workspace.\n\t#[error(\"not a repository: {path}\")]\n\tNotARepository {\n\t\t/// Directory the lookup started from.\n\t\tpath: PathBuf,\n\t},\n\n\t/// A named ref (branch, tag, `refs/...`) does not exist.\n\t#[error(\"reference not found: {name}\")]\n\tRefNotFound {\n\t\t/// The ref name as given by the caller.\n\t\tname: String,\n\t},\n\n\t/// A revision/object lookup failed (`rev-parse` style spec, blob path,\n\t/// tree).\n\t#[error(\"object not found: {spec}\")]\n\tObjectNotFound {\n\t\t/// The revision or object spec as given by the caller.\n\t\tspec: String,\n\t},\n\n\t/// Cherry-picking `sha` produced an empty commit (already applied or\n\t/// auto-resolved to HEAD). Callers should skip and continue the range —\n\t/// replaces the historical `/the previous cherry-pick is now empty/` stderr\n\t/// regex.\n\t#[error(\"cherry-pick of {sha} is empty\")]\n\tEmptyCherryPick {\n\t\t/// The commit that collapsed to a no-op.\n\t\tsha: String,\n\t},\n\n\t/// A merge-style operation (cherry-pick, stash pop, 3-way apply) hit\n\t/// conflicting changes.\n\t#[error(\"merge conflict in {} file(s)\", paths.len())]","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-vcs/src/error.rs#L13-L49","documentation":"Error::ObjectNotFound is raised when a revision or object lookup fails — a `rev-parse`-style spec, a blob path, or a tree entry could not be resolved to an object in the repository database. Unlike RefNotFound, this covers any object spec (SHAs, ranges, path@rev), not just named refs.","triggerScenarios":"Resolving a revision spec that does not parse to an object (misspelled SHA, abbreviated SHA too short/ambiguous-pruned, `HEAD~50` beyond history in a shallow clone), or reading a blob/tree path that does not exist at the given commit (wrong file path, file not in that revision).","commonSituations":"Shallow or partial clones missing deep history (`git log` beyond the depth), history rewritten by rebase/filter-branch so old SHAs vanished, requesting a path that was renamed or added after the requested commit, or hash from another repo.","solutions":["Verify the spec with `git rev-parse --verify <spec>^{object}` before calling the API.","Unshallow the clone if the object predates the shallow boundary: `git fetch --unshallow`.","List the tree at the commit (`git ls-tree <rev>`) to confirm the exact blob path.","If the SHA came from external output, re-fetch the source repo or use the ref name instead of the (rewritten) SHA."],"exampleFix":"// before\nlet blob = repo.read_blob(\"a1b2c3\", \"src/config.json\")?; // path absent at that rev\n// after\nlet commit = repo.resolve(\"a1b2c3\")?;\nlet blob = match repo.read_blob(commit, \"src/config.json\") {\n    Ok(b) => b,\n    Err(Error::ObjectNotFound { .. }) => repo.read_blob(\"HEAD\", \"src/config.json\")?,\n    Err(e) => return Err(e),\n};","handlingStrategy":"validation","validationCode":"fn object_exists(repo: &pi_vcs::Vcs, spec: &str) -> bool {\n    repo.resolve(spec).is_ok()\n}\n// for blob paths, check the tree first:\nfn blob_exists_at(repo: &pi_vcs::Vcs, rev: &str, path: &str) -> bool {\n    repo.list_tree(rev).map(|t| t.iter().any(|e| e.path == path)).unwrap_or(false)\n}","typeGuard":"fn is_object_not_found(err: &pi_vcs::Error) -> bool {\n    matches!(err, pi_vcs::Error::ObjectNotFound { .. })\n}","tryCatchPattern":"match repo.read_blob(rev, path) {\n    Err(pi_vcs::Error::ObjectNotFound { spec }) if spec == path => {\n        eprintln!(\"`{path}` does not exist at `{rev}`\");\n    }\n    Err(pi_vcs::Error::ObjectNotFound { .. }) => {\n        eprintln!(\"revision unreachable — try `git fetch --unshallow`\");\n    }\n    other => other?,\n}","preventionTips":["Verify specs with `git rev-parse --verify <spec>^{object}` before feeding them to APIs.","Avoid full-history lookups on shallow clones; unshallow or widen the fetch depth if deep history is needed.","Confirm blob paths with `git ls-tree <rev>` when the file may have been renamed/added later.","Reference commits by ref name rather than rewritten SHAs after rebases or history edits."],"tags":["vcs","git","object-not-found","revision"],"backgroundTag":"git-object-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}