theonedev/onedev · error · RuntimeException

Malformed review requirement

Error message

Malformed review requirement

What it means

ReviewRequirement.parse uses an ANTLR lexer with a custom BaseErrorListener; any tokenization failure of the review requirement expression is converted to a plain RuntimeException with this message. It means the requirement string does not conform to the ReviewRequirement grammar, so no review requirement can be built. It is thrown from the lexer stage, before any user/group resolution happens.

Source

Thrown at server-core/src/main/java/io/onedev/server/util/reviewrequirement/ReviewRequirement.java:43

	public ReviewRequirement(List<User> users, Map<Group, Integer> groups) {
		this.users = users;
		this.groups = groups;
	}
	
	public static ReviewRequirement parse(@Nullable String requirementString) {
		List<User> users = new ArrayList<>();
		Map<Group, Integer> groups = new LinkedHashMap<>();
		
		if (requirementString != null) {
			CharStream is = CharStreams.fromString(requirementString); 
			ReviewRequirementLexer lexer = new ReviewRequirementLexer(is);
			lexer.removeErrorListeners();
			lexer.addErrorListener(new BaseErrorListener() {

				@Override
				public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
						int charPositionInLine, String msg, RecognitionException e) {
					throw new RuntimeException("Malformed review requirement");
				}
				
			});
			CommonTokenStream tokens = new CommonTokenStream(lexer);
			ReviewRequirementParser parser = new ReviewRequirementParser(tokens);
			parser.removeErrorListeners();
			parser.setErrorHandler(new BailErrorStrategy());
			
			RequirementContext requirementContext = parser.requirement();
			
			for (CriteriaContext criteria: requirementContext.criteria()) {
				if (criteria.userCriteria() != null) {
					String userName = getValue(criteria.userCriteria().Value());
					User user = OneDev.getInstance(UserService.class).findByName(userName);
					if (user != null) {
						if (!users.contains(user)) 
							users.add(user);
						else 

View on GitHub (pinned to d44925c47c)

Solutions

  1. Fix the review requirement syntax (quote user/group names, balance parentheses, use valid criteria keywords)
  2. Check for shell/YAML quoting that stripped or mangled quotes in the stored requirement string
  3. Catch RuntimeException and surface a message pointing at the invalid requirement text

Example fix

// before
reviewRequirement = "developers (2";
// after
reviewRequirement = "(group:developers and 2)";
Defensive patterns

Strategy: validation

Validate before calling

try {
    ReviewRequirement.parse(requirementString);
} catch (RuntimeException e) {
    throw new ExplicitException("Invalid review requirement: " + requirementString);
}

Try / catch

try {
    ReviewRequirement.parse(req);
} catch (RuntimeException e) {
    log.error("Malformed review requirement: {}", req, e);
}

Prevention

When it happens

Trigger: Calling ReviewRequirement.parse (via reviewRequirement) with a syntactically invalid expression, e.g. missing quotes around a user name, unbalanced parentheses, or unknown tokens like 'usr: bob'.

Common situations: Typo'd or hand-edited review requirement in branch protection / pull request review settings; copying requirements between tools with slightly different syntax; shell escaping stripping quotes so the parser sees raw characters.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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