{"record":{"id":"f703d5aea406f5d8","repo":"theonedev/onedev","slug":"unable-to-find-blob-path-in-revision","errorCode":null,"errorMessage":"Unable to find blob path '' in revision ''","messagePattern":"Unable to find blob path '' in revision ''","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/git/GitUtils.java","lineNumber":242,"sourceCode":"\t\treturn diffs;\n\t}\n\n\tstatic void configureDiffFormatter(DiffFormatter diffFormatter, Repository repository) {\n\t\tdiffFormatter.setRepository(repository);\n\t\tdiffFormatter.setDetectRenames(true);\n\t\tdiffFormatter.getRenameDetector().setRenameLimit(-1);\n\t\tdiffFormatter.setDiffComparator(RawTextComparator.DEFAULT);\n\t}\n\n\tpublic static InputStream getInputStream(Repository repository, ObjectId revId, String path) {\n\t\ttry (RevWalk revWalk = new RevWalk(repository)) {\n\t\t\tRevTree revTree = revWalk.parseCommit(revId).getTree();\n\t\t\tTreeWalk treeWalk = TreeWalk.forPath(repository, path, revTree);\n\t\t\tif (treeWalk != null) {\n\t\t\t\tObjectLoader objectLoader = treeWalk.getObjectReader().open(treeWalk.getObjectId(0));\n\t\t\t\treturn objectLoader.openStream();\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundException(\"Unable to find blob path '\" + path + \"' in revision '\" + revId + \"'\");\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n\t\n\tpublic static Collection<String> getBlobPaths(Repository repository, ObjectId commitId) {\n\t\tCollection<String> blobPaths = new HashSet<>();\n\t\ttry (RevWalk revWalk = new RevWalk(repository);\n\t\t\t TreeWalk treeWalk = new TreeWalk(repository)) {\n\t\t\tRevCommit commit = revWalk.parseCommit(commitId);\n\t\t\ttreeWalk.addTree(commit.getTree());\n\t\t\ttreeWalk.setRecursive(true);\n\t\t\ttreeWalk.setFilter(TreeFilter.ANY_DIFF);\n\t\t\t\n\t\t\twhile (treeWalk.next()) {\n\t\t\t\tblobPaths.add(treeWalk.getPathString());\n\t\t\t}","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/git/GitUtils.java#L224-L260","documentation":"GitUtils.getInputStream opens a blob stream at a given path in a revision. It uses TreeWalk.forPath to locate the path inside the commit's tree; when the path does not exist in that revision it throws NotFoundException with a message embedding the path and revision. This is a lookup failure on repository content, not an I/O error.","triggerScenarios":"Calling getInputStream(repository, revId, path) where TreeWalk.forPath(repository, path, revTree) returns null: path absent at that revision, path refers to a directory, wrong case, or the revision predates/postdates the file.","commonSituations":"Rendering a file from an old commit after it was renamed/deleted; deep-linking to a blob at a branch that moved; path separator or case mismatch; passing a commit id that is not the one containing the file.","solutions":["Verify the file exists at that revision: git cat-file -e <revId>:<path>","Check the exact path including case and directory prefix at that commit (git ls-tree -r <revId>)","Resolve the correct revision (the commit where the file exists) before calling","If the path may be missing, pre-check with TreeWalk.forPath yourself or handle NotFoundException"],"exampleFix":"// before\ntry (InputStream is = GitUtils.getInputStream(repo, revId, \"src/App.java\")) { ... }\n\n// after\nTreeWalk tw = TreeWalk.forPath(repo, \"src/App.java\", revWalk.parseCommit(revId).getTree());\nif (tw != null) {\n    try (InputStream is = GitUtils.getInputStream(repo, revId, \"src/App.java\")) { ... }\n} else {\n    LOG.warn(\"Path src/App.java missing at \" + revId.getName());\n}","handlingStrategy":"try-catch","validationCode":"TreeWalk tw = TreeWalk.forPath(repository, path, new RevWalk(repository).parseCommit(revId).getTree());\nboolean exists = (tw != null);","typeGuard":null,"tryCatchPattern":"try (InputStream is = GitUtils.getInputStream(repo, revId, path)) {\n  // consume stream\n} catch (NotFoundException e) {\n  LOG.warn(\"Blob \" + path + \" not present at \" + revId.getName());\n  renderPlaceholder();\n}","preventionTips":["Check path existence at the exact revision before streaming","Remember revisions may predate/postdate the file (renames, deletions)","Match path case and separators exactly as committed"],"tags":["git","blob","file-not-found","onedev"],"backgroundTag":"file-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"}