theonedev/onedev · error · InUseException
${inUseMessage}
Error message
${inUseMessage} What it means
Usage.checkInUse(thing) calls getInUseMessage(thing); if a non-null message is returned it throws InUseException with that message. It guards destructive operations (delete/update) on entities still referenced elsewhere, and callers like checkUsage rely on it to block the operation.
Source
Thrown at server-core/src/main/java/io/onedev/server/util/usage/Usage.java:57
if (!places.isEmpty()) {
StringBuilder builder = new StringBuilder(thing + " is still being used in below places:\n");
for (String place: places) {
if (!place.startsWith("->"))
builder.append(" -> " + place).append("\n");
else
builder.append(" " + place).append("\n");
}
String message = builder.toString();
return message.substring(0, message.length()-1);
} else {
return null;
}
}
public void checkInUse(String thing) {
String inUseMessage = getInUseMessage(thing);
if (inUseMessage != null)
throw new InUseException(inUseMessage);
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Remove the references reported in the in-use message, then retry delete/update
- Call getInUseMessage beforehand and display it to the user instead of attempting the operation
- Catch InUseException around delete/update and surface the message in the UI
Example fix
// before
groupService.delete(group);
// after
String inUse = groupService.getInUseMessage(group);
if (inUse == null) {
groupService.delete(group);
} else {
throw new ExplicitException(inUse);
} Defensive patterns
Strategy: try-catch
Validate before calling
String inUse = entityService.getInUseMessage(entity);
if (inUse != null) {
throw new ExplicitException(inUse);
} Try / catch
try {
service.delete(entity);
} catch (InUseException e) {
ui.showError(e.getMessage());
} Prevention
- Check getInUseMessage before offering destructive actions in UI
- Resolve references (members, authorizations, job usages) before deletion
- Surface the in-use message instead of a generic delete failure
When it happens
Trigger: Calling delete or update on an entity (project, group, role, etc.) that other entities still reference; the concrete message comes from the subclass's getInUseMessage implementation.
Common situations: Deleting a group that still has members or is referenced by authorizations; removing a build spec or secret still used by jobs; cascade deletes attempted manually instead of via the guarded API.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Cannot delete pull request "${request.getReference().toStrin
- errorMessage (from checkDeleteSourceBranchCondition)
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/b4622c7fad99335f.
Report an issue: GitHub.