getgrav/grav · error · RuntimeException
Failed to rename file: PLUGIN_ADMIN.BAD_FILENAME
Error message
Failed to rename file: PLUGIN_ADMIN.BAD_FILENAME
What it means
Error "Failed to rename file: PLUGIN_ADMIN.BAD_FILENAME" thrown in getgrav/grav.
Source
Thrown at system/src/Grav/Common/Media/Traits/MediaUploadTrait.php:395
* Rename file inside the media collection.
*
* @param string $from
* @param string $to
* @param array|null $settings
*/
public function renameFile(string $from, string $to, ?array $settings = null): void
{
// Add the defaults to the settings.
$settings = $this->getUploadSettings($settings);
$filesystem = Filesystem::getInstance(false);
// This method had no filename validation at all. It has no callers in core
// today, but it is part of the public MediaUploadInterface, so a plugin can
// reach it directly. Both names are checked the same way deleteFile() does.
if (!$this->checkFilepath($from) || !Utils::checkFilename($filesystem->basename($from))
|| !$this->checkFilepath($to) || !Utils::checkFilename($filesystem->basename($to))) {
// TODO: translate error message
throw new RuntimeException('Failed to rename file: ' . $this->translate('PLUGIN_ADMIN.BAD_FILENAME'), 400);
}
$path = $settings['destination'] ?? $this->getPath();
if (!$path) {
// TODO: translate error message
throw new RuntimeException('Failed to rename file: Bad destination', 400);
}
/** @var UniformResourceLocator $locator */
$locator = $this->getGrav()['locator'];
$locator->clearCache();
// Get base name of the file.
$pathname = $filesystem->pathname($from);
// Remove @2x, @3x and .meta.yaml
[$base, $ext,,] = $this->getFileParts($filesystem->basename($from));
$from = "{$pathname}{$base}.{$ext}";View on GitHub (pinned to 6040efed04)
When it happens
Trigger: Thrown at system/src/Grav/Common/Media/Traits/MediaUploadTrait.php:395 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17).
Data as JSON: /api/errors/26dce003a0a661cc.
Report an issue: GitHub.