{"record":{"id":"6a79a3f4a0a28a3b","repo":"theonedev/onedev","slug":"invalid-boolean-value","errorCode":null,"errorMessage":"Invalid boolean value","messagePattern":"Invalid boolean value","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/booleaninput/BooleanInput.java","lineNumber":45,"sourceCode":"\t\tinputSpec.appendField(buffer, index, \"Boolean\");\n\t\tinputSpec.appendCommonAnnotations(buffer, index);\n\t\tbuffer.append(\"    @NotNull(message=\\\"May not be empty\\\")\\n\");\n\t\tinputSpec.appendMethods(buffer, index, \"Boolean\", null, defaultValueProvider);\n\t\t\n\t\treturn buffer.toString();\n\t}\n\n\tpublic static Object convertToObject(List<String> strings) {\n\t\tif (strings.size() == 0) {\n\t\t\treturn false;\n\t\t} else if (strings.size() == 1) {\n\t\t\tString string = strings.iterator().next();\n\t\t\tif (string.equalsIgnoreCase(\"true\") || string.equalsIgnoreCase(TextUtils.getDisplayValue(true)))\n\t\t\t\treturn true;\n\t\t\telse if (string.equalsIgnoreCase(\"false\") || string.equalsIgnoreCase(TextUtils.getDisplayValue(false)))\n\t\t\t\treturn false;\n\t\t\telse\n\t\t\t\tthrow new ValidationException(\"Invalid boolean value\");\n\t\t} else {\n\t\t\tthrow new ValidationException(\"Not eligible for multi-value\");\n\t\t}\n\t}\n\n\tpublic static List<String> convertToStrings(Object value) {\n\t\tif (value instanceof Boolean)\n\t\t\treturn Lists.newArrayList(TextUtils.getDisplayValue((Boolean)value));\n\t\telse\n\t\t\treturn Lists.newArrayList(TextUtils.getDisplayValue(false));\n\t}\n\n}\n","sourceCodeStart":27,"sourceCodeEnd":59,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/booleaninput/BooleanInput.java#L27-L59","documentation":"BooleanInput.convertToObject parses user-supplied string values for a boolean job input and throws this validation error when the single value is neither 'true' nor the localized display value of true nor 'false' — i.e. the input text is not a recognized boolean.","triggerScenarios":"Calling BooleanInput.convertToObject with a one-element list whose string is not 'true', 'false', nor TextUtils.getDisplayValue(true/false) (case-insensitive), e.g. 'yes', '1', 'TRUE ' with trailing space, or 'enabled'.","commonSituations":"Buildspec or job boolean input populated by hand or by a script using shell-style 'yes/no' or 0/1 conventions; values exported from another tool with different boolean spellings; whitespace or encoding issues in edited spec files.","solutions":["Use the literal strings 'true' or 'false' (any casing) for the boolean input value.","Normalize alternative spellings ('yes'/'no', '1'/'0', 'on'/'off') to true/false before the call.","Trim whitespace and check for invisible characters in the spec value."],"exampleFix":"// before\nObject value = BooleanInput.convertToObject(Lists.newArrayList(\"yes\"));\n\n// after\nObject value = BooleanInput.convertToObject(Lists.newArrayList(\"true\"));","handlingStrategy":"validation","validationCode":"boolean validBooleanString(String s) {\n    if (s == null) return false;\n    s = s.trim();\n    return s.equalsIgnoreCase(\"true\") || s.equalsIgnoreCase(\"false\");\n}","typeGuard":"boolean isBooleanLiteral(String s) {\n    return \"true\".equalsIgnoreCase(s) || \"false\".equalsIgnoreCase(s);\n}","tryCatchPattern":"try {\n    Object flag = BooleanInput.convertToObject(Lists.newArrayList(value));\n} catch (ValidationException e) {\n    // value must be 'true' or 'false' (case-insensitive)\n}","preventionTips":["Normalize 'yes/no', '1/0', 'on/off' to 'true'/'false' before conversion.","Trim whitespace and avoid invisible characters in spec files."],"tags":["validation","buildspec","boolean","input-parsing"],"backgroundTag":"invalid-argument-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}