theonedev/onedev · error · NotFoundException
Unable to find path " + nonExistPath
Error message
Unable to find path " + nonExistPath
What it means
During a tree-writing operation in DefaultGitService (blob edits batched into a single commit), the code walks the existing tree matching the paths the caller wants to modify/delete. If some requested old paths were never matched against any existing tree entry, the tree does not contain them and a NotFoundException is thrown from insertTree. OneDev throws this so that blob-edit requests referencing non-existent files fail fast instead of silently producing a wrong commit.
Source
Thrown at server-core/src/main/java/io/onedev/server/git/service/DefaultGitService.java:751
childTreeWalk.enterSubtree();
ObjectId childTreeId = insertTree(revTree, childTreeWalk, inserter, treeWalk.getPathString(),
childOldPaths, childNewBlobs);
if (childTreeId != null)
entries.add(new TreeFormatterEntry(name, FileMode.TREE.getBits(), childTreeId));
} else {
throw new NotTreeException("Path does not represent a tree: " + treeWalk.getPathString());
}
} else {
entries.add(new TreeFormatterEntry(name, treeWalk.getFileMode(0).getBits(), treeWalk.getObjectId(0)));
}
}
}
if (!currentOldPaths.isEmpty()) {
String nonExistPath = currentOldPaths.iterator().next();
if (parentPath != null)
nonExistPath = parentPath + "/" + nonExistPath;
throw new NotFoundException("Unable to find path " + nonExistPath);
}
if (!currentNewBlobs.isEmpty()) {
Set<String> files = new HashSet<>();
for (Map.Entry<String, BlobContent> entry : currentNewBlobs.entrySet()) {
String path = entry.getKey();
if (!path.contains("/")) {
files.add(path);
entries.add(new TreeFormatterEntry(path, entry.getValue().getMode(),
inserter.insert(Constants.OBJ_BLOB, entry.getValue().getBytes())));
files.add(path);
}
}
Set<String> topLevelPathSegments = new LinkedHashSet<>();
for (String path : currentNewBlobs.keySet()) {
if (path.contains("/")) {
String topLevelPathSegment = StringUtils.substringBefore(path, "/");
if (files.contains(topLevelPathSegment)) {View on GitHub (pinned to d44925c47c)
Solutions
- Verify the path exists in the target commit before editing/deleting (list blobs of the commit or use getBlob).
- Refresh your view/branch state — another commit may have removed or renamed the file; rebase or re-fetch.
- Check path spelling and case exactly as stored in git (git ls-tree -r <commit>).
- If the delete is idempotent by design, first check existence and skip the edit when the path is absent.
Example fix
// before
gitService.commitBlobEdits(projectId, refName, blobEdits, ...); // assumes file exists
// after
if (gitService.getBlobs(projectId, revision, blobEdits.getOldPaths()).size() != blobEdits.getOldPaths().size()) {
throw new ValidationException("One or more paths no longer exist on " + refName);
}
gitService.commitBlobEdits(projectId, refName, blobEdits, ...); Defensive patterns
Strategy: validation
Validate before calling
Set<String> missing = blobEdits.getOldPaths().stream()
.filter(p -> gitService.getBlob(projectId, revision, p) == null)
.collect(Collectors.toSet());
if (!missing.isEmpty()) throw new ValidationException("Paths not on " + revision + ": " + missing); Try / catch
try { gitService.commitBlobEdits(...); } catch (NotFoundException e) { log.warn("path vanished: {}", e.getMessage()); refreshAndRetryOrSkip(); } Prevention
- Check path existence before batch edit/delete calls
- Re-read ref state immediately before committing edits in multi-user repos
- Match paths with exact case as stored in git
When it happens
Trigger: Calling the git service to update/delete blobs (BlobIdent old paths via BlobEdits / commitBlobEdits-style APIs) where at least one oldPath does not exist in the parent commit's tree, e.g. deleting a file that was already removed or editing a file at a misspelled path.
Common situations: Editing or deleting a file in a project via the web/API after another commit already deleted or renamed it; case-sensitivity mismatches (file renamed with different casing); stale client state attempting to delete an already-removed path; path typos in scripted API calls.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Project not found or inaccessible: <projectPath>
- Branch not exist:
- Commit not found: ${commitHash}
- Ref name is required when commit hash is specified
- Either commit hash, branch or tag should be specified
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/c998f8b0be8e8422.
Report an issue: GitHub.