{"record":{"id":"5131d1ea289a4145","repo":"zed-industries/zed","slug":"expected-commit-object-got-object-type","errorCode":null,"errorMessage":"expected commit object, got {object_type}","messagePattern":"expected commit object, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git/src/repository.rs","lineNumber":3583,"sourceCode":"            ))\n        }\n        .boxed()\n    }\n\n    fn commit_data_reader(&self) -> Result<CommitDataReader> {\n        let git_binary = self.git_binary();\n\n        let (request_tx, request_rx) = async_channel::bounded::<CommitDataRequest>(64);\n\n        let task = self.executor.spawn(async move {\n            if let Err(error) = run_commit_data_reader(git_binary, request_rx).await {\n                log::error!(\"commit data reader failed: {error:?}\");\n            }\n        });\n\n        Ok(CommitDataReader {\n            request_tx,\n            _task: task,\n        })\n    }\n\n    fn set_trusted(&self, trusted: bool) {\n        self.is_trusted\n            .store(trusted, std::sync::atomic::Ordering::Release);\n    }\n\n    fn is_trusted(&self) -> bool {\n        self.is_trusted.load(std::sync::atomic::Ordering::Acquire)\n    }\n}\n\nasync fn run_commit_data_reader(\n    git: GitBinary,\n    request_rx: async_channel::Receiver<CommitDataRequest>,\n) -> Result<()> {\n    let mut process = git","sourceCodeStart":3565,"sourceCodeEnd":3601,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/git/src/repository.rs#L3565-L3601","documentation":"cat-file --batch resolved the requested SHA, but the object's type is not `commit` — it is a blob, tree, or annotated tag. The commit-loading path only accepts commit objects, so it refuses with the actual type name in the message.","triggerScenarios":"Passing a blob OID (for example a file blob SHA captured from blame or the index) or a tree OID (from `git ls-tree` / `rev-parse HEAD^{tree}`) where a commit SHA is expected; passing an annotated-tag OID without dereferencing it to the commit it points at.","commonSituations":"OIDs collected from mixed git commands fed into a commit-metadata lookup; short SHAs resolving to an unexpected object in tag-heavy repositories; storing `git rev-parse <tag>` output (tag object) instead of `<tag>^{commit}`.","solutions":["Dereference to a commit before loading: resolve with `git rev-parse <spec>^{commit}` and use the resulting SHA.","Check the type first: `git cat-file -t <oid>` and skip non-commit objects.","When capturing SHAs to pass around, always capture commit OIDs (from `rev-parse HEAD`-style calls, never tree or blob OIDs).","Treat tag objects as expected input and peel them (`^{}` / `^{commit}`) rather than erroring."],"exampleFix":"// before\nlet commit_sha = tree_oid_captured_from_ls_tree;\n// after\nlet commit_sha = git\n    .run(&[\"rev-parse\", &format!(\"{spec}^{{commit}}\")])\n    .await?\n    .trim()\n    .to_string();","handlingStrategy":"type-guard","validationCode":"// peel any spec to a commit OID before the commit-loading call\nlet commit_sha = git\n    .run(&[\"rev-parse\", &format!(\"{spec}^{{commit}}\")])\n    .await?;\nlet commit_sha = commit_sha.trim();","typeGuard":"async fn resolves_to_commit(git: &GitBinary, spec: &str) -> bool {\n    git.run(&[\"cat-file\", \"-t\", spec]).await\n        .map(|t| t.trim() == \"commit\")\n        .unwrap_or(false)\n}","tryCatchPattern":"match load_commits(&shas).await {\n    Err(e) if e.to_string().contains(\"expected commit object\") => {\n        // peel with ^{commit} and retry, or drop the non-commit OIDs\n    }\n    other => other?,\n}","preventionTips":["Always peel refs and tags with `^{commit}` before commit lookups.","Store only commit OIDs when persisting references for later commit loads.","Check `git cat-file -t` on OIDs of mixed provenance (index, ls-tree, blame) before use."],"tags":["git","cat-file","object-type","tag"],"backgroundTag":"git-wrong-object-type","analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}