{"record":{"id":"809f3aaa06fa1580","repo":"theonedev/onedev","slug":"undefined-state","errorCode":null,"errorMessage":"Undefined state: ","messagePattern":"Undefined state: ","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/model/Issue.java","lineNumber":464,"sourceCode":"\tprivate transient Collection<User> participants;\n\t\n\tprivate transient Collection<User> authorizedUsers;\n\n\tprivate transient Optional<String> branchOptional;\n\n\tprivate transient Optional<Build> fieldBuildOptional;\n\n\tprivate transient Optional<ObjectId> fieldCommitIdOptional;\n\t\n\tpublic String getState() {\n\t\treturn state;\n\t}\n\n\tpublic void setState(String state) {\n\t\tthis.state = state;\n\t\tstateOrdinal = getIssueSetting().getStateOrdinal(state);\n\t\tif (stateOrdinal == -1)\n\t\t\tthrow new ExplicitException(\"Undefined state: \" + state);\n\t}\n\n\tpublic int getStateOrdinal() {\n\t\treturn stateOrdinal;\n\t}\n\n\tpublic void setStateOrdinal(int stateOrdinal) {\n\t\tthis.stateOrdinal = stateOrdinal;\n\t}\n\n\tpublic String getTitle() {\n\t\treturn title;\n\t}\n\n\tpublic void setTitle(String title) {\n\t\tthis.title = StringUtils.abbreviate(title, MAX_TITLE_LEN);\n\t}\n","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/model/Issue.java#L446-L482","documentation":"Issue.setState maps a state name to its ordinal via the project's issue settings. If the name is not one of the configured states, stateOrdinal is -1 and ExplicitException 'Undefined state: <state>' is thrown.","triggerScenarios":"Calling setState (directly or via API/scripts) with a state name that does not exist in the project's issue state configuration; state renamed in settings while old name persists in scripts/forms.","commonSituations":"Custom states changed in Issue Settings after automation scripts referenced old names; importing issues across projects with different state lists; case mismatch ('Open' vs 'open').","solutions":["Use a state name exactly as configured in the project's Issue Settings state list","Update scripts/API calls after renaming states","Add the missing state to the issue settings if it should exist","Check case and whitespace in the supplied state name"],"exampleFix":"// before\nissue.setState(\"Closed\");   // project only has \"Closed Done\"\n// after\nissue.setState(\"Closed Done\");","handlingStrategy":"validation","validationCode":"List<String> states = project.getIssueSetting().getStateSpecs().stream().map(StateSpec::getName).toList(); if (!states.contains(state)) throw new IllegalArgumentException(\"Unknown state: \" + state);","typeGuard":null,"tryCatchPattern":"try { issue.setState(state); } catch (ExplicitException e) { throw new BadRequestException(e.getMessage()); }","preventionTips":["Derive state names from Issue Settings at runtime instead of hardcoding","Update automation when states are renamed","Match exact case/whitespace of configured state names"],"tags":["issues","state","validation"],"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"}