theonedev/onedev · error · NotFoundException
Unable to find blob ident:
Error message
Unable to find blob ident:
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/model/Project.java:831
public Blob getBlob(BlobIdent blobIdent, boolean mustExist) {
Preconditions.checkArgument(blobIdent.revision!=null && blobIdent.path!=null && blobIdent.mode!=null,
"Revision, path and mode of ident param should be specified");
Optional<Blob> blobOptional = getBlobCache().get(blobIdent);
if (blobOptional == null) {
ObjectId revId = getObjectId(blobIdent.revision, mustExist);
if (revId != null) {
Blob blob = getGitService().getBlob(this, revId, blobIdent.path);
if (blob != null)
blob = new Blob(blobIdent, blob.getBlobId(), blob.getBytes(), blob.getSize());
blobOptional = Optional.fromNullable(blob);
} else {
blobOptional = Optional.absent();
}
getBlobCache().put(blobIdent, blobOptional);
}
if (mustExist && !blobOptional.isPresent())
throw new NotFoundException("Unable to find blob ident: " + blobIdent);
else
return blobOptional.orNull();
}
public BlobIdent findBlobIdent(ObjectId revId, String path) {
return getGitService().getBlobIdent(this, revId, path);
}
/**
* Get cached object id of specified revision.
*
* @param revision
* revision to resolve object id for
* @param mustExist
* true to have the method throwing exception instead
* of returning null if the revision does not exist
* @return
* object id of specified revision, or <tt>null</tt> if revision View on GitHub (pinned to d44925c47c)
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.
Example fix
// before
Blob blob = project.getBlob(blobIdent, true);
// after
BlobIdent ident = project.findBlobIdent(revId, path);
if (ident != null && ident.isBlob()) { Blob blob = project.getBlob(ident, true); ... } else { /* handle missing file */ } Defensive patterns
Strategy: validation
Validate before calling
BlobIdent ident = project.findBlobIdent(revId, path);
if (ident == null || !ident.isBlob()) { /* handle missing file or directory path */ } Type guard
if (ident != null && ident.isBlob()) { Blob blob = project.getBlob(ident, true); ... } Try / catch
try { Blob blob = project.getBlob(blobIdent, true); } catch (NotFoundException e) { // render 'file not found at revision' UI } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- Unable to find blob path '<path>' in revision '<revision>'
- Unable to find commit to import build spec (import project:
- Unable to find blob path '' in revision ''
- Path '" + blobIdent.path + "' is a tree"
- Unable to find revision ''
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/635f4a23782d4136.
Report an issue: GitHub.