{"record":{"id":"4893ab1e4d6397df","repo":"theonedev/onedev","slug":"not-eligible-for-multi-value-4893ab","errorCode":null,"errorMessage":"Not eligible for multi-value","messagePattern":"Not eligible for multi-value","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/PullRequestChoiceInput.java","lineNumber":37,"sourceCode":"\t\t\tbuffer.append(\"    @NotNull\\n\");\n\t\tbuffer.append(\"    @PullRequestChoice(useNumber=true)\\n\");\n\t\tinputSpec.appendMethods(buffer, index, \"Long\", null, null);\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\tString value = strings.iterator().next();\n\t\t\ttry {\n\t\t\t\treturn Long.valueOf(value);\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new ValidationException(\"Invalid pull request id/number\");\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 Long)\n\t\t\treturn Lists.newArrayList(value.toString());\n\t\telse\n\t\t\treturn new ArrayList<>();\n\t}\n\n}\n","sourceCodeStart":19,"sourceCodeEnd":49,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspecmodel/inputspec/PullRequestChoiceInput.java#L19-L49","documentation":"PullRequestChoiceInput.convertToObject accepts at most one value; it converts a single string to a Long pull request id/number. When the input list contains more than one element it throws 'Not eligible for multi-value', because this input type is defined as single-choice.","triggerScenarios":"Calling PullRequestChoiceInput.convertToObject with a List<String> of size > 1, e.g. multiple selected pull requests supplied where only one is allowed.","commonSituations":"A buildspec or job input marked as a pull-request choice (single value) is fed a comma-separated or multi-selected list from a script or automation; a UI/form change started sending multiple values without switching the input to multi-value mode.","solutions":["Supply exactly one pull request id/number string in the list.","If multiple values are truly needed, enable multi-value on the input definition instead of passing a list.","Split or reduce upstream data (e.g. take the first or reject extra values) before calling convertToObject."],"exampleFix":"// before\nList<String> vals = Lists.newArrayList(\"12\", \"15\");\nObject value = PullRequestChoiceInput.convertToObject(vals); // throws\n\n// after\nList<String> vals = Lists.newArrayList(\"12\");\nObject value = PullRequestChoiceInput.convertToObject(vals);","handlingStrategy":"validation","validationCode":"boolean singleValue(List<String> strings) {\n    return strings != null && strings.size() <= 1;\n}","typeGuard":null,"tryCatchPattern":"try {\n    Object pr = PullRequestChoiceInput.convertToObject(values);\n} catch (ValidationException e) {\n    // input is single-choice; reduce values to one element\n}","preventionTips":["Remember pull-request choice inputs are single-valued; enable multi-value on the input if lists are expected.","Collapse or reject multi-element lists upstream before conversion."],"tags":["validation","buildspec","multi-value"],"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-14T05:17:10.506Z"}