octobercms/october · error · ApplicationException

File ':name' already exists.

Error message

File ':name' already exists.

What it means

Uniqueness check in Asset::save: the target file path already exists on disk while the fileName differs from originalFileName (i.e. a rename), so saving would silently overwrite an existing theme asset. The duplicate name is the fault.

Solutions

  1. Choose a different file name for the asset
  2. Rename or delete the existing conflicting file in the theme
  3. If overwrite is intended, keep the same fileName rather than renaming
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/cms/classes/Asset.php:307 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at modules/cms/classes/Asset.php:307

                    ['name' => $key]
                ));
            }

            $this->$key = $value;
        }
    }

    /**
     * save the object to the disk
     */
    public function save()
    {
        $this->validateFileName();

        $fullPath = $this->getFilePath();

        if (File::isFile($fullPath) && $this->originalFileName !== $this->fileName) {
            throw new ApplicationException(Lang::get(
                'cms::lang.cms_object.file_already_exists',
                ['name'=>$this->fileName]
            ));
        }

        $dirPath = $this->theme->getPath().'/'.$this->dirName;
        if (!file_exists($dirPath) || !is_dir($dirPath)) {
            if (!File::makeDirectory($dirPath, 0755, true, true)) {
                throw new ApplicationException(Lang::get(
                    'cms::lang.cms_object.error_creating_directory',
                    ['name'=>$dirPath]
                ));
            }
        }

        if (($pos = strpos($this->fileName, '/')) !== false) {
            $dirPath = dirname($fullPath);

View on GitHub (pinned to b608633a7e)