{"record":{"id":"40e34ff3e7fa24c7","repo":"theonedev/onedev","slug":"invalid-boolean-value-40e34f","errorCode":null,"errorMessage":"Invalid boolean: ${value}","messagePattern":"Invalid boolean: (.+?)","errorType":"exception","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/QueryUtils.java","lineNumber":115,"sourceCode":"\t\tif (group == null)\n\t\t\tthrow new NotFoundException(\"Unable to find group: \" + groupName);\n\t\treturn group;\n\t}\n\t\n\tpublic static Project getProject(String projectPath) {\n\t\tProject project = OneDev.getInstance(ProjectService.class).findByPath(projectPath);\n\t\tif (project == null)\n\t\t\tthrow new NotFoundException(\"Unable to find project '\" + projectPath + \"'\");\n\t\treturn project;\n\t}\n\t\n\tpublic static boolean getBooleanValue(String value) {\n\t\tif (value.equals(\"true\"))\n\t\t\treturn true;\n\t\telse if (value.equals(\"false\"))\n\t\t\treturn false;\n\t\telse\n\t\t\tthrow new NotAcceptableException(\"Invalid boolean: \" + value);\n\t}\n\t\n\tpublic static Date getDateValue(String value) {\n\t\tDate dateValue = DateUtils.parseRelaxed(value);\n\t\tif (dateValue == null)\n\t\t\tthrow new NotAcceptableException(\"Unrecognized date: \" + value);\n\t\treturn dateValue;\n\t}\n\n\tpublic static ProjectScopedCommit getCommitId(@Nullable Project project, String value) {\n\t\tif (project != null && !value.contains(\":\"))\n\t\t\tvalue = project.getPath() + \":\" + value;\n\t\tProjectScopedCommit commitId = ProjectScopedCommit.from(value);\n\t\tif (commitId != null && commitId.getCommitId() != null)\n\t\t\treturn commitId;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Unable to find revision: \" + value);\n\t}","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/QueryUtils.java#L97-L133","documentation":"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.","triggerScenarios":"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 \".","commonSituations":"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.","solutions":["Change the value to lowercase \"true\" or \"false\" exactly, with no whitespace or quotes","Trim and lowercase the input before passing it in: value.trim().toLowerCase() only helps if the original was 'True' not '1'/'yes'","If parsing user input, normalize booleans yourself with Boolean.parseBoolean inside try/catch before calling the utility","Catch NotAcceptableException and report the accepted literals (true/false) to the user"],"exampleFix":"// before\nboolean flag = QueryUtils.getBooleanValue(\"True\");\n// after\nboolean flag = QueryUtils.getBooleanValue(\"true\");","handlingStrategy":"validation","validationCode":"if (!\"true\".equals(value) && !\"false\".equals(value))\n    throw new UserException(\"Value must be exactly 'true' or 'false': \" + value);","typeGuard":"Boolean asStrictBoolean(String s) {\n    return \"true\".equals(s) ? Boolean.TRUE : \"false\".equals(s) ? Boolean.FALSE : null;\n}","tryCatchPattern":"try {\n    boolean flag = QueryUtils.getBooleanValue(value);\n} catch (NotAcceptableException e) {\n    // normalize: value.trim().toLowerCase() and retry, or reject input\n}","preventionTips":["Always lowercase and trim boolean input before use","Reject '1'/'0'/'yes'/'no' spellings early in your own input validation"],"tags":["boolean","parsing","validation","onedev"],"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"}