{"record":{"id":"2e654e974bdee8bb","repo":"theonedev/onedev","slug":"invalid-number-value","errorCode":null,"errorMessage":"Invalid number: ${value}","messagePattern":"Invalid number: (.+?)","errorType":"exception","errorClass":"NotAcceptableException","httpStatus":406,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/util/QueryUtils.java","lineNumber":51,"sourceCode":"import io.onedev.server.service.LabelSpecService;\nimport io.onedev.server.service.ProjectService;\nimport io.onedev.server.service.PullRequestService;\nimport io.onedev.server.service.SettingService;\nimport io.onedev.server.service.UserService;\n\npublic class QueryUtils {\n\n\tprivate static final Pattern INSIDE_QUOTE = Pattern.compile(\"\\\"([^\\\"\\\\\\\\]|\\\\\\\\.)*\");\n\n\tpublic static String getValue(String token) {\n\t\treturn StringUtils.unescape(FenceAware.unfence(token));\n\t}\n\t\n\tpublic static int getIntValue(String value) {\n\t\ttry {\n\t\t\treturn Integer.parseInt(value);\n\t\t} catch (NumberFormatException e) {\n\t\t\tthrow new NotAcceptableException(\"Invalid number: \" + value);\n\t\t}\n\t}\n\n\tpublic static float getFloatValue(String value) {\n\t\ttry {\n\t\t\treturn Float.parseFloat(value);\n\t\t} catch (NumberFormatException e) {\n\t\t\tthrow new NotAcceptableException(\"Invalid decimal: \" + value);\n\t\t}\n\t}\n\t\n\tpublic static LabelSpec getLabelSpec(String labelName) {\n\t\tvar labelSpec = OneDev.getInstance(LabelSpecService.class).find(labelName);\n\t\tif (labelSpec != null) \n\t\t\treturn labelSpec;\n\t\telse\n\t\t\tthrow new NotFoundException(\"Undefined label: \" + labelName);\n\t}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/QueryUtils.java#L33-L69","documentation":"QueryUtils.getIntValue converts a query field value string to an int via Integer.parseInt. When the value is not a valid integer, it throws NotAcceptableException with this message, surfacing a user-entered query operand error as a 4xx-style validation failure.","triggerScenarios":"Using a non-integer operand (e.g. 'abc', '1.5', '', '99999999999') for an integer-typed issue field in an issue query or REST query parameter parsed through QueryUtils.","commonSituations":"Typing a decimal or text into a numeric query criterion; pasting values with whitespace or thousands separators; overflow beyond Integer.MAX_VALUE; saved query broken after field type changed.","solutions":["Correct the query operand to a whole number within int range (e.g. 5 instead of 5.5)","Strip whitespace/quotes around the value","Use getFloatValue-style comparison or a different field type if a decimal is intended"],"exampleFix":"// before\ngetIntValue(\"3.5\"); // throws\n// after\nint v = QueryUtils.getIntValue(String.valueOf(Math.round(Float.parseFloat(\"3.5\")))); // 4","handlingStrategy":"validation","validationCode":"function isInt(v) { return /^-?\\d+$/.test(v.trim()) && Number.isInteger(Number(v)); }","typeGuard":"boolean isValidInt(String v) {\n    try { Integer.parseInt(v.trim()); return true; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try {\n    int v = QueryUtils.getIntValue(raw);\n} catch (NotAcceptableException e) {\n    // reject or re-prompt for the query operand\n}","preventionTips":["Validate numeric operands client-side before building queries","Never paste locale-formatted numbers (spaces, commas) into query fields","Check int range before submitting large values"],"tags":["query","validation","parsing","onedev"],"backgroundTag":"invalid-number-format","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"}