jenkinsci/jenkins · warning · Failure
The name “{0}” is already in use.
Error message
The name “{0}” is already in use. What it means
Thrown by checkIfNameIsUsed(newName) when a same-named item already exists in the parent and the current user can see it (getItem returns non-null without ACL elevation). The localized 'NewNameInUse' message tells the user the name is taken. This is the straightforward collision case — the rename would create a duplicate.
Source
Thrown at core/src/main/java/hudson/model/AbstractItem.java:312
}
Jenkins.get().getProjectNamingStrategy().checkName(getParent().getFullName(), newName);
checkIfNameIsUsed(newName);
checkRename(newName);
} catch (Failure e) {
return FormValidation.error(e.getMessage());
}
return FormValidation.ok();
}
/**
* Check new name for job
* @param newName - New name for job.
*/
private void checkIfNameIsUsed(@NonNull String newName) throws Failure {
try {
Item item = getParent().getItem(newName);
if (item != null) {
throw new Failure(Messages.AbstractItem_NewNameInUse(newName));
}
try (ACLContext ctx = ACL.as2(ACL.SYSTEM2)) {
item = getParent().getItem(newName);
if (item != null) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Unable to rename the job {0}: name {1} is already in use. " +
"User {2} has no {3} permission for existing job with the same name",
new Object[] {this.getFullName(), newName, ctx.getPreviousContext2().getAuthentication().getName(), Item.DISCOVER.name});
}
// Don't explicitly mention that there is another item with the same name.
throw new Failure(Messages.Jenkins_NotAllowedName(newName));
}
}
} catch (AccessDeniedException ex) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Unable to rename the job {0}: name {1} is already in use. " +
"User {2} has {3} permission, but no {4} for existing job with the same name",
new Object[] {this.getFullName(), newName, User.current(), Item.DISCOVER.name, Item.READ.name});View on GitHub (pinned to 2e228ff40b)
Solutions
- Choose a unique new name that does not exist in the same parent folder
- Check for collisions before submitting: call getParent().getItem(newName) and validate
- If the target item is one you intend to replace, delete or rename it first
- Be aware of case-insensitive matching on Windows/macOS filesystems
Example fix
// before: rename blindly
item.renameTo(takenName);
// after: check first
if (item.getParent().getItem(takenName) != null) {
throw new Failure("Name '" + takenName + "' is already in use");
}
item.renameTo(takenName); Defensive patterns
Strategy: validation
Validate before calling
if (item.getParent().getItem(newName) != null) {
throw new IllegalStateException("Name '" + newName + "' already exists in parent");
} Try / catch
try {
// rename flow
} catch (Failure f) {
if (f.getMessage().contains("already in use")) {
// prompt user for a different name
}
throw f;
} Prevention
- Check getParent().getItem(newName) for collisions before submitting a rename
- Be aware of case-insensitive filesystems on Windows/macOS
- In automation, compute unique names or pre-check existence
When it happens
Trigger: During a rename, checkIfNameIsUsed calls getParent().getItem(newName); if non-null (and visible to the caller), it throws Failure with AbstractItem_NewNameInUse.
Common situations: Renaming a job to a name that matches an existing job in the same folder; case-insensitive collisions on case-insensitive filesystems; automation scripts computing new names that clash.
Related errors
- Trying to rename an item that does not support this operatio
- New name is not given
- “{0}” is not an allowed name
- No ancestor of type {} in the request
- A logger named "{0}" does not exist. Add a logger by this na
AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14).
Data as JSON: /api/errors/e6154fd0754f282c.
Report an issue: GitHub.