{"record":{"id":"fa6cee5dd89d48d9","repo":"theonedev/onedev","slug":"unknown-revision-type","errorCode":null,"errorMessage":"Unknown revision type","messagePattern":"Unknown revision type","errorType":"validation","errorClass":"ExplicitException","httpStatus":500,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/commit/CommitQuery.java","lineNumber":114,"sourceCode":"\t\t\t\t} else if (criteria.pathCriteria() != null) {\n\t\t\t\t\tfor (var value: criteria.pathCriteria().Value())\n\t\t\t\t\t\tcriteriaValues.computeIfAbsent(PathCriteria.class, k->new ArrayList<>()).add(getValue(value));\n\t\t\t\t} else if (criteria.beforeCriteria() != null) {\n\t\t\t\t\tcriteriaValues.computeIfAbsent(BeforeCriteria.class, k->new ArrayList<>()).add(getValue(criteria.beforeCriteria().Value()));\n\t\t\t\t} else if (criteria.afterCriteria() != null) {\n\t\t\t\t\tcriteriaValues.computeIfAbsent(AfterCriteria.class, k->new ArrayList<>()).add(getValue(criteria.afterCriteria().Value()));\n\t\t\t\t} else if (criteria.revisionCriteria() != null) {\n\t\t\t\t\tRevision.Type type;\n\t\t\t\t\tif (criteria.revisionCriteria().BRANCH() != null || criteria.revisionCriteria().DefaultBranch() != null) \n\t\t\t\t\t\ttype = Revision.Type.BRANCH;\n\t\t\t\t\telse if (criteria.revisionCriteria().TAG() != null)\n\t\t\t\t\t\ttype = Revision.Type.TAG;\n\t\t\t\t\telse if (criteria.revisionCriteria().COMMIT() != null)\n\t\t\t\t\t\ttype = Revision.Type.COMMIT;\n\t\t\t\t\telse if (criteria.revisionCriteria().BUILD() != null)\n\t\t\t\t\t\ttype = Revision.Type.BUILD;\n\t\t\t\t\telse\n\t\t\t\t\t\tthrow new ExplicitException(\"Unknown revision type\");\n\n\t\t\t\t\tvar isSince = criteria.revisionCriteria().SINCE() != null;\n\n\t\t\t\t\tif (criteria.revisionCriteria().DefaultBranch() != null) {\n\t\t\t\t\t\tcriteriaValues.computeIfAbsent(RevisionCriteria.class, k->new ArrayList<>()).add(new Revision(type, null, isSince));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (var valueNode: criteria.revisionCriteria().Value()) {\n\t\t\t\t\t\t\tcriteriaValues.computeIfAbsent(RevisionCriteria.class, k->new ArrayList<>()).add(new Revision(type, getValue(valueNode), isSince));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (criteria.orderCriteria() != null) {\n\t\t\t\t\tOrder orderValue;\n\t\t\t\t\tif (criteria.orderCriteria().OrderByDate() != null) {\n\t\t\t\t\t\torderValue = Order.DATE;\n\t\t\t\t\t} else if (criteria.orderCriteria().OrderByAuthorDate() != null) {\n\t\t\t\t\t\torderValue = Order.AUTHOR_DATE;\n\t\t\t\t\t} else if (criteria.orderCriteria().OrderByTopo() != null) {\n\t\t\t\t\t\torderValue = Order.TOPO;","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/commit/CommitQuery.java#L96-L132","documentation":"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.","triggerScenarios":"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.","commonSituations":"Rarely user-caused; appears after grammar changes in custom builds, mismatched generated parser classes, or plugin code feeding hand-built parse trees.","solutions":["Ensure the query string uses a supported revision type keyword (branch, tag, commit, build).","Regenerate/rebuild the ANTLR parser classes if you modified the grammar (out-of-sync generated code).","Update OneDev to a version whose CommitQuery grammar matches your query syntax; catch ExplicitException for graceful handling."],"exampleFix":"// before\nCommitQuery.parse(project, \"since mysterytype(foo)\", false);\n// after\nCommitQuery.parse(project, \"since build(#123)\", false);","handlingStrategy":"try-catch","validationCode":"Set<String> valid = Set.of(\"branch\", \"tag\", \"commit\", \"build\");\nMatcher m = Pattern.compile(\"(?i)(since|until)\\\\s+(\\\\w+)\\\\s*\\\\(\").matcher(q);\nif (m.find() && !valid.contains(m.group(2).toLowerCase()))\n    throw new IllegalArgumentException(\"Unknown revision type: \" + m.group(2));","typeGuard":null,"tryCatchPattern":"try {\n    return CommitQuery.parse(project, q, false);\n} catch (ExplicitException e) {\n    if (\"Unknown revision type\".equals(e.getMessage()))\n        throw new UserFriendlyException(\"Revision type must be branch, tag, commit or build\");\n    throw e;\n}","preventionTips":["Only use documented revision type keywords in since/until criteria","Keep generated ANTLR classes in sync with the grammar after custom changes","Catch ExplicitException around parse in all query entry points"],"tags":["commit-search","parsing","antlr"],"backgroundTag":"invalid-enum-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}