theonedev/onedev · error · NotAcceptableException

Invalid boolean: ${value}

Error message

Invalid boolean: ${value}

What it means

QueryUtils.getBooleanValue parses a string that must be exactly "true" or "false" (case-sensitive). Any other string throws a NotAcceptableException. It is used when query/criteria values carry boolean literals, so a malformed value in a query reaches this method.

Source

Thrown at server-core/src/main/java/io/onedev/server/util/QueryUtils.java:115

		if (group == null)
			throw new NotFoundException("Unable to find group: " + groupName);
		return group;
	}
	
	public static Project getProject(String projectPath) {
		Project project = OneDev.getInstance(ProjectService.class).findByPath(projectPath);
		if (project == null)
			throw new NotFoundException("Unable to find project '" + projectPath + "'");
		return project;
	}
	
	public static boolean getBooleanValue(String value) {
		if (value.equals("true"))
			return true;
		else if (value.equals("false"))
			return false;
		else
			throw new NotAcceptableException("Invalid boolean: " + value);
	}
	
	public static Date getDateValue(String value) {
		Date dateValue = DateUtils.parseRelaxed(value);
		if (dateValue == null)
			throw new NotAcceptableException("Unrecognized date: " + value);
		return dateValue;
	}

	public static ProjectScopedCommit getCommitId(@Nullable Project project, String value) {
		if (project != null && !value.contains(":"))
			value = project.getPath() + ":" + value;
		ProjectScopedCommit commitId = ProjectScopedCommit.from(value);
		if (commitId != null && commitId.getCommitId() != null)
			return commitId;
		else
			throw new NotFoundException("Unable to find revision: " + value);
	}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Change the value to lowercase "true" or "false" exactly, with no whitespace or quotes
  2. Trim and lowercase the input before passing it in: value.trim().toLowerCase() only helps if the original was 'True' not '1'/'yes'
  3. If parsing user input, normalize booleans yourself with Boolean.parseBoolean inside try/catch before calling the utility
  4. Catch NotAcceptableException and report the accepted literals (true/false) to the user

Example fix

// before
boolean flag = QueryUtils.getBooleanValue("True");
// after
boolean flag = QueryUtils.getBooleanValue("true");
Defensive patterns

Strategy: validation

Validate before calling

if (!"true".equals(value) && !"false".equals(value))
    throw new UserException("Value must be exactly 'true' or 'false': " + value);

Type guard

Boolean asStrictBoolean(String s) {
    return "true".equals(s) ? Boolean.TRUE : "false".equals(s) ? Boolean.FALSE : null;
}

Try / catch

try {
    boolean flag = QueryUtils.getBooleanValue(value);
} catch (NotAcceptableException e) {
    // normalize: value.trim().toLowerCase() and retry, or reject input
}

Prevention

When it happens

Trigger: Calling QueryUtils.getBooleanValue with any string other than exactly "true" or "false" — e.g. "True", "TRUE", "1", "yes", or a value with whitespace like " true ".

Common situations: Query criteria values typed with different casing ('True'); using 1/0 or yes/no instead of true/false; values copied from JSON/YAML with surrounding quotes or whitespace; localized 'true'/'false' words.

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/40e34ff3e7fa24c7. Report an issue: GitHub.