octobercms/october · error · SystemException

The image editing session is not found.

Error message

The image editing session is not found.

What it means

SystemException thrown in cropImage() (MediaManager.php:1937) when the working directory for the supplied cropSessionKey does not exist under temp_path(). Crop sessions are created when the crop popup opens (files staged in a session-scoped temp directory); if that directory is gone by apply time, the session is considered expired.

Source

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

        $selectionParams = ['x', 'y', 'w', 'h'];

        foreach ($selectionParams as $paramName) {
            if (!array_key_exists($paramName, $selectionData)) {
                throw new SystemException('Invalid selection data.');
            }

            if (!is_numeric($selectionData[$paramName])) {
                throw new SystemException('Invalid selection data.');
            }

            $selectionData[$paramName] = (int) $selectionData[$paramName];
        }

        $sessionDirectoryPath = $this->getCropSessionDirPath($cropSessionKey);
        $fullSessionDirectoryPath = temp_path($sessionDirectoryPath);

        if (!File::isDirectory($fullSessionDirectoryPath)) {
            throw new SystemException('The image editing session is not found.');
        }

        // Find the image on the disk and resize it
        $imagePath = $fullSessionDirectoryPath.'/'.$fileName;
        if (!File::isFile($imagePath)) {
            throw new SystemException('The image is not found on the disk.');
        }

        if (!$this->validateFileType($originalFileName)) {
            throw new ApplicationException(Lang::get('backend::lang.media.type_blocked'));
        }

        $extension = pathinfo($originalFileName, PATHINFO_EXTENSION);

        $targetImageName = basename($originalFileName, '.'.$extension).'-'
            .$selectionData['x'].'-'
            .$selectionData['y'].'-'
            .$selectionData['w'].'-'

View on GitHub (pinned to b608633a7e)

Solutions

  1. Close and reopen the crop popup to start a fresh crop session (new key, re-staged original).
  2. Use shared, persistent storage for the temp directory in multi-server setups (configure the CMS temp path to a mounted volume).
  3. Exclude the app temp path from tmp-reaper/cron cleanup jobs and container ephemeral mounts.
Defensive patterns

Strategy: retry

Validate before calling

// Client-side: on session-not-found, transparently restart the crop flow
if (response.error && /editing session is not found/.test(response.error)) {
    return startNewCropSession(path); // reopen popup, get fresh key
}

Try / catch

try {
    $this->cropImage($src, $selection, $key, $path);
} catch (\System\Classes\SystemException $e) {
    if (strpos($e->getMessage(), 'editing session is not found') !== false) {
        $key = str_random(); // start over: stage again, then retry once
        $this->getImageUrl($path, $key, null);
        return $this->cropImage($src, $selection, $key, $path);
    }
    throw $e;
}

Prevention

When it happens

Trigger: Posting a stale, malformed, or garbage-collected cropSessionKey to the crop apply (or resize) handler; temp files swept by an aggressive cleaner or a container restart between opening the popup and applying the crop.

Common situations: User leaves the crop popup open for a long time on a host that purges /tmp aggressively; multiple load-balanced app nodes without shared temp storage; key mismatch after re-opening the popup concurrently in another tab.

Related errors


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