theonedev/onedev · error · ExplicitException
Undefined state:
Error message
Undefined state:
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/model/Issue.java:464
private transient Collection<User> participants;
private transient Collection<User> authorizedUsers;
private transient Optional<String> branchOptional;
private transient Optional<Build> fieldBuildOptional;
private transient Optional<ObjectId> fieldCommitIdOptional;
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
stateOrdinal = getIssueSetting().getStateOrdinal(state);
if (stateOrdinal == -1)
throw new ExplicitException("Undefined state: " + state);
}
public int getStateOrdinal() {
return stateOrdinal;
}
public void setStateOrdinal(int stateOrdinal) {
this.stateOrdinal = stateOrdinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = StringUtils.abbreviate(title, MAX_TITLE_LEN);
}
View on GitHub (pinned to d44925c47c)
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
Example fix
// before
issue.setState("Closed"); // project only has "Closed Done"
// after
issue.setState("Closed Done"); Defensive patterns
Strategy: validation
Validate before calling
List<String> states = project.getIssueSetting().getStateSpecs().stream().map(StateSpec::getName).toList(); if (!states.contains(state)) throw new IllegalArgumentException("Unknown state: " + state); Try / catch
try { issue.setState(state); } catch (ExplicitException e) { throw new BadRequestException(e.getMessage()); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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').
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Title is required
- Issue ${issueReference} is not in current project
- Invalid issue id/number
- Not eligible for multi-value
- Subject required to open issue via email
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/809f3aaa06fa1580.
Report an issue: GitHub.