{"record":{"id":"1da067ec93e4539f","repo":"jenkinsci/jenkins","slug":"new-name-is-not-given","errorCode":null,"errorMessage":"New name is not given","messagePattern":"New name is not given","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/model/AbstractItem.java","lineNumber":370,"sourceCode":"     * Not all the Items need to support this operation, but if you decide to do so,\n     * you can use this method.\n     */\n    @SuppressFBWarnings(value = \"SWL_SLEEP_WITH_LOCK_HELD\", justification = \"no big deal\")\n    protected void renameTo(final String newName) throws IOException {\n\n        if (!isNameEditable()) {\n            throw new IOException(\"Trying to rename an item that does not support this operation.\");\n        }\n\n        // always synchronize from bigger objects first\n        final ItemGroup parent = getParent();\n        String oldName = this.name;\n        String oldFullName = getFullName();\n        synchronized (parent) {\n            synchronized (this) {\n                // sanity check\n                if (newName == null)\n                    throw new IllegalArgumentException(\"New name is not given\");\n\n                // noop?\n                if (this.name.equals(newName))\n                    return;\n\n                // the lookup is case insensitive, so we should not fail if this item was the “existing” one\n                // to allow people to rename \"Foo\" to \"foo\", for example.\n                // see http://www.nabble.com/error-on-renaming-project-tt18061629.html\n                Items.verifyItemDoesNotAlreadyExist(parent, newName, this);\n\n                File oldRoot = this.getRootDir();\n\n                doSetName(newName);\n                File newRoot = this.getRootDir();\n\n                boolean success = false;\n\n                try { // rename data files","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/model/AbstractItem.java#L352-L388","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Validate newName is non-null and non-blank before calling renameTo","In Stapler request handlers, use req.getSubmittedForm() validation or @RequirePOST with a required field check","Return a FormValidation.error or Failure for blank names instead of reaching the IllegalArgumentException"],"exampleFix":"// before\nitem.renameTo(newName /* could be null */);\n// after\nif (newName == null || newName.isBlank()) {\n    throw new Failure(\"A new name is required\");\n}\nitem.renameTo(newName);","handlingStrategy":"validation","validationCode":"if (newName == null || newName.isBlank()) {\n    throw new IllegalArgumentException(\"newName must be non-null and non-blank\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate newName is non-null and non-blank at the API boundary before calling renameTo","In Stapler handlers, require and validate the name form field","Use parameter validation in REST/CLI rename endpoints"],"tags":["item","rename","null-argument","validation","programming-error"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}