{"record":{"id":"1755b66066e40805","repo":"octobercms/october","slug":"cms-lang-asset-name-cant-be-empty","errorCode":null,"errorMessage":"cms::lang.asset.name_cant_be_empty","messagePattern":"cms::lang\\.asset\\.name_cant_be_empty","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/media/widgets/MediaManager.php","lineNumber":411,"sourceCode":"        $this->vars['listId'] = Input::get('listId');\n        $this->vars['type'] = Input::get('type');\n\n        return $this->makePartial('rename-form');\n    }\n\n    /**\n     * onApplyName renames an item\n     * @return array\n     */\n    public function onApplyName()\n    {\n        if (!$this->checkHasPermission('mediaDelete')) {\n            throw new ForbiddenException;\n        }\n\n        $newName = trim(Input::get('name'));\n        if (!strlen($newName)) {\n            throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));\n        }\n\n        if (!$this->validateFileName($newName)) {\n            throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));\n        }\n\n        $originalPath = Input::get('originalPath');\n        $originalPath = MediaLibrary::validatePath($originalPath);\n        $newPath = dirname($originalPath).'/'.$newName;\n        $type = Input::get('type');\n\n        if ($type === MediaLibraryItem::TYPE_FILE) {\n            // Validate extension\n            if (!$this->validateFileType($newName)) {\n                throw new ApplicationException(Lang::get('backend::lang.media.type_blocked'));\n            }\n\n            if (Config::get('media.clean_vectors', true) && $this->isVector($newName)) {","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/media/widgets/MediaManager.php#L393-L429","documentation":"MediaManager::onApplyName() renames a library item and first requires a non-empty name: trim(Input::get('name')) must have length. An absent, empty, or whitespace-only name throws cms::lang.asset.name_cant_be_empty before any validation or move happens. The stock rename popup enforces this client-side, so hitting it server-side means a custom client or a scripted request.","triggerScenarios":"Submitting the rename popup with an empty input (enter key on a blank field in a customized form); a scripted request omitting the name field; a value of only spaces or non-breaking spaces that trim reduces to ''.","commonSituations":"Custom rename UIs missing the required attribute; browser autofill quirks clearing the field; API integrations that send originalPath/type but forget name.","solutions":["Mark the rename input required and validate non-empty before posting","Send a trimmed, non-empty name in the request alongside originalPath and type","For scripted renames, guard with if (!strlen(trim($name))) before calling the handler"],"exampleFix":"<!-- before -->\n<input type=\"text\" name=\"name\" id=\"rename-name\" />\n\n<!-- after -->\n<input type=\"text\" name=\"name\" id=\"rename-name\" required=\"required\" />\n\n// JS: block empty submits\nif (!form.name.value.trim()) { alert('Name cannot be empty'); return false; }","handlingStrategy":"validation","validationCode":"const name = (input.value || '').trim();\nif (!name) { alert('Name cannot be empty'); return false; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark rename inputs required and trim before submit","Disable the apply button while the name field is blank","In scripted renames, skip or default empty names before calling onApplyName"],"tags":["media","rename","validation","media-manager"],"backgroundTag":"empty-required-field","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}