{"record":{"id":"d0fe7c77b12ea602","repo":"theonedev/onedev","slug":"invalid-float-value","errorCode":null,"errorMessage":"Invalid float value","messagePattern":"Invalid float value","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/floatinput/FloatInput.java","lineNumber":38,"sourceCode":"\t\tint index = indexes.get(inputSpec.getName());\n\t\tStringBuffer buffer = new StringBuffer();\n\t\tinputSpec.appendField(buffer, index, \"Float\");\n\t\tinputSpec.appendCommonAnnotations(buffer, index);\n\t\tif (!inputSpec.isAllowEmpty())\n\t\t\tbuffer.append(\"    @NotNull(message=\\\"May not be empty\\\")\\n\");\n\t\tinputSpec.appendMethods(buffer, index, \"Float\", 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 null;\n\t\t} else if (strings.size() == 1) {\n\t\t\ttry {\n\t\t\t\treturn Float.valueOf(strings.iterator().next());\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new ValidationException(\"Invalid float value\");\n\t\t\t}\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 Float)\n\t\t\treturn Lists.newArrayList(String.valueOf(value));\n\t\telse\n\t\t\treturn new ArrayList<>();\n\t}\n\n}\n","sourceCodeStart":20,"sourceCodeEnd":53,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/floatinput/FloatInput.java#L20-L53","documentation":"FloatInput.convertToObject parses a single submitted string into a Float via Float.valueOf. When parsing fails (NumberFormatException), it throws ValidationException \"Invalid float value\" because the submitted value is not a valid float literal (empty, non-numeric, out of float range, wrong locale separators).","triggerScenarios":"Calling FloatInput.convertToObject(List<String>) with a single-element list whose string is not parseable by Float.valueOf, e.g. \"abc\", \"\", \"1,5\", \"1e999\".","commonSituations":"User types text or a comma decimal separator into a float input field; a script interpolates an empty variable into a build spec float input; locale-formatted numbers with thousands separators submitted through the API.","solutions":["Correct the submitted value to a valid float literal such as \"3.14\", \"-2\", \"1e3\".","Validate the value client-side (regex like -?\\d+(\\.\\d+)?([eE][+-]?\\d+)?) before submitting.","If the value comes from a variable, check it is not empty at the point of interpolation.","Use a dot as the decimal separator regardless of locale."],"exampleFix":"// before\nString v = props.get(\"threshold\"); // \"1,5\"\nObject f = FloatInput.convertToObject(Lists.newArrayList(v)); // ValidationException\n\n// after\nString v = props.get(\"threshold\").replace(',', '.');\nif (!v.matches(\"-?\\\\d+(\\\\.\\\\d+)?([eE][+-]?\\\\d+)?\"))\n    throw new ValidationException(\"Threshold must be a number\");\nObject f = FloatInput.convertToObject(Lists.newArrayList(v));","handlingStrategy":"validation","validationCode":"if (value != null && !value.matches(\"-?\\\\d+(\\\\.\\\\d+)?([eE][+-]?\\\\d+)?\"))\n    throw new ValidationException(\"Value must be a valid float\");","typeGuard":null,"tryCatchPattern":"try {\n    f = FloatInput.convertToObject(Lists.newArrayList(value));\n} catch (ValidationException e) {\n    // invalid float: re-prompt or default\n}","preventionTips":["Always use '.' as decimal separator before submitting.","Sanitize interpolated shell/environment variables used as float inputs.","Validate numeric fields client-side with a float regex."],"tags":["validation","input-spec","float","number-format"],"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"}