theonedev/onedev · error · IllegalArgumentException
Bad object type {0}
Error message
Bad object type {0} What it means
RevWalk.parseAny/parseCommit-style entry points inspect the object type stored in the repository (commit, tree, blob, tag). When the object database returns a type constant outside the known set (0 or >4), the walk cannot build a RevObject for it and throws this IllegalArgumentException. This normally indicates a corrupt or non-standard object in the repository.
Source
Thrown at server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java:1219
}
case Constants.OBJ_TREE: {
r = new RevTree(id);
r.flags |= PARSED;
break;
}
case Constants.OBJ_BLOB: {
r = new RevBlob(id);
r.flags |= PARSED;
break;
}
case Constants.OBJ_TAG: {
final RevTag t = new RevTag(id);
t.parseCanonical(this, getCachedBytes(t, ldr));
r = t;
break;
}
default:
throw new IllegalArgumentException(MessageFormat.format(
JGitText.get().badObjectType, Integer.valueOf(type)));
}
objects.add(r);
return r;
}
byte[] getCachedBytes(RevObject obj) throws LargeObjectException,
MissingObjectException, IncorrectObjectTypeException, IOException {
return getCachedBytes(obj, reader.open(obj, obj.getType()));
}
byte[] getCachedBytes(RevObject obj, ObjectLoader ldr)
throws LargeObjectException, MissingObjectException, IOException {
try {
return ldr.getCachedBytes(5 * MB);
} catch (LargeObjectException tooBig) {
tooBig.setObjectId(obj);
throw tooBig;View on GitHub (pinned to d44925c47c)
Solutions
- Run 'git fsck --full' on the repository to locate and assess corrupt objects.
- Restore the repository from backup or re-clone from a healthy remote.
- Identify the offending object id from the message/context and repair or remove it.
- If caused by a third-party writer, stop using that writer or upgrade JGit to one supporting the object type.
Defensive patterns
Strategy: try-catch
Validate before calling
// detect corruption ahead of parsing Status s = Git.open(repoDir).getRepository().fsck(); // or run `git fsck --full` via CLI
Type guard
Integer type = repo.open(id).getType(); boolean known = type >= Constants.OBJ_COMMIT && type <= Constants.OBJ_TAG; // 1..4
Try / catch
try {
return walk.parseAny(id);
} catch (IllegalArgumentException e) {
throw new RepositoryCorruptedException("Unrecognized object type for " + id, e);
} Prevention
- Run periodic 'git fsck' health checks on repositories
- Re-clone or restore from backup when corruption is detected
- Avoid writing objects with non-git tooling
- Keep JGit updated for new object-type support
When it happens
Trigger: Parsing an object id whose backing storage reports an unrecognized type constant, e.g. a corrupted loose object header, an object type added by a newer/exotic git implementation, or a pack containing malformed type bits.
Common situations: Repository corruption after disk failure or interrupted gc; reading repositories produced by tools that write non-standard object types; tests feeding fabricated ObjectIds into RevWalk.parseAny.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Ref name is required when commit hash is specified
- Either commit hash, branch or tag should be specified
- Unable to find commit to import build spec (import project:
- No default branch in project:
- Ref not found (project:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/a553ef5d11bd36ce.
Report an issue: GitHub.