{"record":{"id":"635f4a23782d4136","repo":"theonedev/onedev","slug":"unable-to-find-blob-ident","errorCode":null,"errorMessage":"Unable to find blob ident: ","messagePattern":"Unable to find blob ident: ","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/model/Project.java","lineNumber":831,"sourceCode":"\tpublic Blob getBlob(BlobIdent blobIdent, boolean mustExist) {\n\t\tPreconditions.checkArgument(blobIdent.revision!=null && blobIdent.path!=null && blobIdent.mode!=null, \n\t\t\t\t\"Revision, path and mode of ident param should be specified\");\n\t\t\n\t\tOptional<Blob> blobOptional = getBlobCache().get(blobIdent);\n\t\tif (blobOptional == null) {\n\t\t\tObjectId revId = getObjectId(blobIdent.revision, mustExist);\t\t\n\t\t\tif (revId != null) { \n\t\t\t\tBlob blob = getGitService().getBlob(this, revId, blobIdent.path);\n\t\t\t\tif (blob != null)\n\t\t\t\t\tblob = new Blob(blobIdent, blob.getBlobId(), blob.getBytes(), blob.getSize());\n\t\t\t\tblobOptional = Optional.fromNullable(blob);\n\t\t\t} else {\n\t\t\t\tblobOptional = Optional.absent();\n\t\t\t}\n\t\t\tgetBlobCache().put(blobIdent, blobOptional);\n\t\t}\n\t\tif (mustExist && !blobOptional.isPresent())\n\t\t\tthrow new NotFoundException(\"Unable to find blob ident: \" + blobIdent);\n\t\telse \n\t\t\treturn blobOptional.orNull();\n\t}\n\t\n\tpublic BlobIdent findBlobIdent(ObjectId revId, String path) {\n\t\treturn getGitService().getBlobIdent(this, revId, path);\n\t}\n\t\n\t/**\n\t * Get cached object id of specified revision.\n\t * \n\t * @param revision\n\t * \t\t\trevision to resolve object id for\n\t * @param mustExist\n\t * \t\t\ttrue to have the method throwing exception instead \n\t * \t\t\tof returning null if the revision does not exist\n\t * @return\n\t * \t\t\tobject id of specified revision, or <tt>null</tt> if revision ","sourceCodeStart":813,"sourceCodeEnd":849,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/model/Project.java#L813-L849","documentation":"Project.getBlob(blobIdent, mustExist) resolves a BlobIdent (revision + path) to a Blob via the git service, caching the result. When mustExist is true and the git repository has no blob at that ident, a NotFoundException with the blob ident is thrown instead of returning null.","triggerScenarios":"Calling project.getBlob(blobIdent, true) where the path does not exist at the given commit/revision, the path is a directory (tree) rather than a file, or the revision is a cached/incorrect id.","commonSituations":"Frontend requests file contents at a revision where the file was later deleted/renamed; passing a directory path instead of a file path; stale client state after force-push/rewrite of history; case-sensitivity mismatch in the path on Linux filesystems.","solutions":["Verify the blob exists first with findBlobIdent(revId, path) or call getBlob(ident, false) and null-check before use.","Confirm the path points to a file (blob), not a directory, at that revision.","Refresh the revision being used — it may be stale after history changes (force-push, rebase).","Check path spelling/case exactly matches the repository."],"exampleFix":"// before\nBlob blob = project.getBlob(blobIdent, true);\n// after\nBlobIdent ident = project.findBlobIdent(revId, path);\nif (ident != null && ident.isBlob()) { Blob blob = project.getBlob(ident, true); ... } else { /* handle missing file */ }","handlingStrategy":"validation","validationCode":"BlobIdent ident = project.findBlobIdent(revId, path);\nif (ident == null || !ident.isBlob()) { /* handle missing file or directory path */ }","typeGuard":"if (ident != null && ident.isBlob()) { Blob blob = project.getBlob(ident, true); ... }","tryCatchPattern":"try { Blob blob = project.getBlob(blobIdent, true); } catch (NotFoundException e) { // render 'file not found at revision' UI }","preventionTips":["Use findBlobIdent or mustExist=false to probe before fetching","Verify paths reference blobs, not trees","Re-resolve revisions after history rewrites; watch path case sensitivity"],"tags":["git","blob","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"}