octobercms/october · error · ApplicationException

cms::lang.asset.name_cant_be_empty

Error message

cms::lang.asset.name_cant_be_empty

What it means

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.

Source

Thrown at modules/media/widgets/MediaManager.php:411

        $this->vars['listId'] = Input::get('listId');
        $this->vars['type'] = Input::get('type');

        return $this->makePartial('rename-form');
    }

    /**
     * onApplyName renames an item
     * @return array
     */
    public function onApplyName()
    {
        if (!$this->checkHasPermission('mediaDelete')) {
            throw new ForbiddenException;
        }

        $newName = trim(Input::get('name'));
        if (!strlen($newName)) {
            throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));
        }

        if (!$this->validateFileName($newName)) {
            throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
        }

        $originalPath = Input::get('originalPath');
        $originalPath = MediaLibrary::validatePath($originalPath);
        $newPath = dirname($originalPath).'/'.$newName;
        $type = Input::get('type');

        if ($type === MediaLibraryItem::TYPE_FILE) {
            // Validate extension
            if (!$this->validateFileType($newName)) {
                throw new ApplicationException(Lang::get('backend::lang.media.type_blocked'));
            }

            if (Config::get('media.clean_vectors', true) && $this->isVector($newName)) {

View on GitHub (pinned to b608633a7e)

Solutions

  1. Mark the rename input required and validate non-empty before posting
  2. Send a trimmed, non-empty name in the request alongside originalPath and type
  3. For scripted renames, guard with if (!strlen(trim($name))) before calling the handler

Example fix

<!-- before -->
<input type="text" name="name" id="rename-name" />

<!-- after -->
<input type="text" name="name" id="rename-name" required="required" />

// JS: block empty submits
if (!form.name.value.trim()) { alert('Name cannot be empty'); return false; }
Defensive patterns

Strategy: validation

Validate before calling

const name = (input.value || '').trim();
if (!name) { alert('Name cannot be empty'); return false; }

Prevention

When it happens

Trigger: 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 ''.

Common situations: Custom rename UIs missing the required attribute; browser autofill quirks clearing the field; API integrations that send originalPath/type but forget name.

Related errors


AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21). Data as JSON: /api/errors/1755b66066e40805. Report an issue: GitHub.