theonedev/onedev · error · ExplicitException

Unknown revision type

Error message

Unknown revision type

What it means

When parsing a revision criterion (e.g. since/until revision), CommitQuery.parse determines the Revision.Type from the recognized token (BRANCH→TAG→COMMIT→BUILD checks). If none of the expected tokens matched, it throws ExplicitException 'Unknown revision type' — an internal invariant guard over the grammar alternatives.

Source

Thrown at server-core/src/main/java/io/onedev/server/search/commit/CommitQuery.java:114

				} else if (criteria.pathCriteria() != null) {
					for (var value: criteria.pathCriteria().Value())
						criteriaValues.computeIfAbsent(PathCriteria.class, k->new ArrayList<>()).add(getValue(value));
				} else if (criteria.beforeCriteria() != null) {
					criteriaValues.computeIfAbsent(BeforeCriteria.class, k->new ArrayList<>()).add(getValue(criteria.beforeCriteria().Value()));
				} else if (criteria.afterCriteria() != null) {
					criteriaValues.computeIfAbsent(AfterCriteria.class, k->new ArrayList<>()).add(getValue(criteria.afterCriteria().Value()));
				} else if (criteria.revisionCriteria() != null) {
					Revision.Type type;
					if (criteria.revisionCriteria().BRANCH() != null || criteria.revisionCriteria().DefaultBranch() != null) 
						type = Revision.Type.BRANCH;
					else if (criteria.revisionCriteria().TAG() != null)
						type = Revision.Type.TAG;
					else if (criteria.revisionCriteria().COMMIT() != null)
						type = Revision.Type.COMMIT;
					else if (criteria.revisionCriteria().BUILD() != null)
						type = Revision.Type.BUILD;
					else
						throw new ExplicitException("Unknown revision type");

					var isSince = criteria.revisionCriteria().SINCE() != null;

					if (criteria.revisionCriteria().DefaultBranch() != null) {
						criteriaValues.computeIfAbsent(RevisionCriteria.class, k->new ArrayList<>()).add(new Revision(type, null, isSince));
					} else {
						for (var valueNode: criteria.revisionCriteria().Value()) {
							criteriaValues.computeIfAbsent(RevisionCriteria.class, k->new ArrayList<>()).add(new Revision(type, getValue(valueNode), isSince));
						}
					}
				} else if (criteria.orderCriteria() != null) {
					Order orderValue;
					if (criteria.orderCriteria().OrderByDate() != null) {
						orderValue = Order.DATE;
					} else if (criteria.orderCriteria().OrderByAuthorDate() != null) {
						orderValue = Order.AUTHOR_DATE;
					} else if (criteria.orderCriteria().OrderByTopo() != null) {
						orderValue = Order.TOPO;

View on GitHub (pinned to d44925c47c)

Solutions

  1. Ensure the query string uses a supported revision type keyword (branch, tag, commit, build).
  2. Regenerate/rebuild the ANTLR parser classes if you modified the grammar (out-of-sync generated code).
  3. Update OneDev to a version whose CommitQuery grammar matches your query syntax; catch ExplicitException for graceful handling.

Example fix

// before
CommitQuery.parse(project, "since mysterytype(foo)", false);
// after
CommitQuery.parse(project, "since build(#123)", false);
Defensive patterns

Strategy: try-catch

Validate before calling

Set<String> valid = Set.of("branch", "tag", "commit", "build");
Matcher m = Pattern.compile("(?i)(since|until)\\s+(\\w+)\\s*\\(").matcher(q);
if (m.find() && !valid.contains(m.group(2).toLowerCase()))
    throw new IllegalArgumentException("Unknown revision type: " + m.group(2));

Try / catch

try {
    return CommitQuery.parse(project, q, false);
} catch (ExplicitException e) {
    if ("Unknown revision type".equals(e.getMessage()))
        throw new UserFriendlyException("Revision type must be branch, tag, commit or build");
    throw e;
}

Prevention

When it happens

Trigger: A revisionCriteria context whose type token matches none of DEFAULT, BRANCH, TAG, COMMIT, BUILD — usually only possible with grammar/parser drift or corrupted input contexts, surfaced during CommitQuery.parse.

Common situations: Rarely user-caused; appears after grammar changes in custom builds, mismatched generated parser classes, or plugin code feeding hand-built parse trees.

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


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/fa6cee5dd89d48d9. Report an issue: GitHub.