jenkinsci/jenkins · error · IllegalArgumentException

New name is not given

Error message

New name is not given

What it means

Thrown by AbstractItem.renameTo(newName) as an IllegalArgumentException when newName is null. This is a programming-error guard inside the synchronized rename block — the caller must supply a non-null new name. It indicates a bug in the calling code rather than a user-facing condition.

Source

Thrown at core/src/main/java/hudson/model/AbstractItem.java:370

     * Not all the Items need to support this operation, but if you decide to do so,
     * you can use this method.
     */
    @SuppressFBWarnings(value = "SWL_SLEEP_WITH_LOCK_HELD", justification = "no big deal")
    protected void renameTo(final String newName) throws IOException {

        if (!isNameEditable()) {
            throw new IOException("Trying to rename an item that does not support this operation.");
        }

        // always synchronize from bigger objects first
        final ItemGroup parent = getParent();
        String oldName = this.name;
        String oldFullName = getFullName();
        synchronized (parent) {
            synchronized (this) {
                // sanity check
                if (newName == null)
                    throw new IllegalArgumentException("New name is not given");

                // noop?
                if (this.name.equals(newName))
                    return;

                // the lookup is case insensitive, so we should not fail if this item was the “existing” one
                // to allow people to rename "Foo" to "foo", for example.
                // see http://www.nabble.com/error-on-renaming-project-tt18061629.html
                Items.verifyItemDoesNotAlreadyExist(parent, newName, this);

                File oldRoot = this.getRootDir();

                doSetName(newName);
                File newRoot = this.getRootDir();

                boolean success = false;

                try { // rename data files

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Validate newName is non-null and non-blank before calling renameTo
  2. In Stapler request handlers, use req.getSubmittedForm() validation or @RequirePOST with a required field check
  3. Return a FormValidation.error or Failure for blank names instead of reaching the IllegalArgumentException

Example fix

// before
item.renameTo(newName /* could be null */);
// after
if (newName == null || newName.isBlank()) {
    throw new Failure("A new name is required");
}
item.renameTo(newName);
Defensive patterns

Strategy: validation

Validate before calling

if (newName == null || newName.isBlank()) {
    throw new IllegalArgumentException("newName must be non-null and non-blank");
}

Prevention

When it happens

Trigger: renameTo(null) is called directly; or a Stapler form binding resolved the new name field to null (e.g. missing form parameter) and the rename path did not validate before calling renameTo.

Common situations: A REST/CLI/automation client omits the new name parameter; a Stapler request with a missing or malformed name field; a plugin calling renameTo with a value computed from untrusted input that resolved to null.

Related errors


AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14). Data as JSON: /api/errors/1da067ec93e4539f. Report an issue: GitHub.