{"record":{"id":"e8ad41dd41eef587","repo":"theonedev/onedev","slug":"unable-to-find-commit-associated-with-object-id","errorCode":null,"errorMessage":"Unable to find commit associated with object id: ${revId}","messagePattern":"Unable to find commit associated with object id: (.+?)","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/model/Project.java","lineNumber":1033,"sourceCode":"\t\tObjectId revId = getObjectId(revision, mustExist);\n\t\tif (revId != null) {\n\t\t\treturn getRevCommit(revId, mustExist);\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\t@Nullable\n\tpublic RevCommit getRevCommit(ObjectId revId, boolean mustExist) {\n\t\tif (commitCache == null)\n\t\t\tcommitCache = new HashMap<>();\n\t\tOptional<RevCommit> commit = commitCache.get(revId);\n\t\tif (commit == null) {\n\t\t\tcommit = Optional.fromNullable(getGitService().getCommit(this, revId));\n\t\t\tcommitCache.put(revId, commit);\n\t\t}\n\t\tif (mustExist && !commit.isPresent())\n\t\t\tthrow new NotFoundException(\"Unable to find commit associated with object id: \" + revId);\n\t\telse\n\t\t\treturn commit.orNull();\n\t}\n\t\n\tpublic Collection<CodeComment> getCodeComments() {\n\t\treturn codeComments;\n\t}\n\n\tpublic void setCodeComments(Collection<CodeComment> codeComments) {\n\t\tthis.codeComments = codeComments;\n\t}\n\t\n\t@Editable(order=250, description=\"Whether or not to enable code management for the project\")\n\tpublic boolean isCodeManagement() {\n\t\treturn codeManagement;\n\t}\n\n\tpublic void setCodeManagement(boolean codeManagement) {","sourceCodeStart":1015,"sourceCodeEnd":1051,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/model/Project.java#L1015-L1051","documentation":"Project.getCommit(revId, mustExist) loads a RevCommit for an ObjectId via the git service (cached). When mustExist is true and the object id does not correspond to any commit in the repository, a NotFoundException is thrown. This differs from error 348: here the id format is valid but the commit object itself is absent (or is not a commit).","triggerScenarios":"project.getCommit(objectId, true) where the ObjectId is not present in the repo (e.g. object garbage-collected, SHA from a different repo, or a non-commit object id such as a tree/blob).","commonSituations":"Referencing commit SHAs after a history rewrite/force-push removed them (or after GC pruned unreachable objects); copying SHAs between forks/repositories; passing a blob/tree object id where a commit is expected; cached ids surviving repository re-import.","solutions":["Resolve commit ids freshly via project.getCommitId(revision, false) instead of caching object ids across history changes.","Verify the SHA exists with git cat-file -t <sha> in the repo (should print 'commit').","Catch NotFoundException and re-resolve from a branch/tag before retrying.","Ensure ids come from the same repository — cross-repo SHAs will not resolve."],"exampleFix":"// before\nRevCommit c = project.getCommit(revId, true); // stale revId after force-push\n// after\nRevCommit c;\ntry { c = project.getCommit(revId, true); }\ncatch (NotFoundException e) { revId = project.getCommitId(project.getDefaultBranch(), false); c = project.getCommit(revId, true); }","handlingStrategy":"try-catch","validationCode":"ObjectId fresh = project.getCommitId(revision, false);\nRevCommit c = (fresh != null) ? project.getCommit(fresh, false) : null;\nif (c == null) { /* handle missing commit */ }","typeGuard":null,"tryCatchPattern":"try { RevCommit c = project.getCommit(revId, true); } catch (NotFoundException e) { // re-resolve revId from a branch/tag before retrying }","preventionTips":["Don't persist ObjectIds long-term; store revision strings and resolve on demand","Avoid referencing SHAs from other repos or post-force-push history","Call with mustExist=false and null-check when absence is expected"],"tags":["git","commit","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}