octobercms/october · error · SystemException

The original image is not found in the cropping session dire

Error message

The original image is not found in the cropping session directory.

What it means

SystemException thrown at MediaManager.php:1847 in the crop flow's second step (target dimensions supplied): the file 'original.<ext>' is expected in the crop session directory but File::isFile() says it is gone. The original was staged there when the crop popup opened (error 590's step), so its disappearance means the session state was lost between the two AJAX calls.

Source

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

                if (!@File::put($tempFilePath, $library->get($path))) {
                    throw new SystemException('Error saving remote file to a temporary location.');
                }

                $url = $this->getThumbnailImageUrl($sessionDirectoryPath.'/'.$originalThumbFileName);
                $dimensions = getimagesize($tempFilePath);

                return [
                    'url' => $url,
                    'dimensions' => $dimensions
                ];
            }

            // If the target dimensions are provided, resize the original image and
            // return its URL and dimensions.
            $originalFilePath = $fullSessionDirectoryPath.'/'.$originalThumbFileName;
            if (!File::isFile($originalFilePath)) {
                throw new SystemException('The original image is not found in the cropping session directory.');
            }

            $resizedThumbFileName = 'resized-'.$params['width'].'-'.$params['height'].'.'.$extension;
            $tempFilePath = $fullSessionDirectoryPath.'/'.$resizedThumbFileName;

            Resizer::open($originalFilePath)
                ->resize($params['width'], $params['height'], [
                    'mode' => 'exact'
                ])
                ->save($tempFilePath)
            ;

            $url = $this->getThumbnailImageUrl($sessionDirectoryPath.'/'.$resizedThumbFileName);
            $dimensions = getimagesize($tempFilePath);

            return [
                'url' => $url,
                'dimensions' => $dimensions

View on GitHub (pinned to b608633a7e)

Solutions

  1. Close and reopen the crop popup — this re-stages the original image and generates a fresh session key.
  2. If you run multiple app servers, point temp_path()/cms temp dir at shared storage (NFS/EFS volume) so crop sessions survive routing across nodes.
  3. Relax or exclude the app temp directory from tmp-reaper cron jobs that delete recent files.
Defensive patterns

Strategy: retry

Validate before calling

// Client-side: if the original is missing, restart the session instead of retrying blindly
if (response.error && /original image is not found/.test(response.error)) {
    return reopenCropPopup(imagePath); // re-stages original.<ext> with a new session key
}

Try / catch

try {
    $this->cropImage($src, $selection, $key, $path);
} catch (\System\Classes\SystemException $e) {
    if (strpos($e->getMessage(), 'original image is not found') !== false) {
        // session expired: re-stage and retry once
        $this->getImageUrl($path, $newKey, null);
        return $this->cropImage($src, $selection, $newKey, $path);
    }
    throw $e;
}

Prevention

When it happens

Trigger: Calling the crop/resize step with a cropSessionKey whose directory no longer contains original.<ext> — because the temp directory was purged (aggressive tmp cleaner, cron deleting files newer than X, container restart with ephemeral /tmp) between opening the popup and applying the resize, or because a different session key was posted.

Common situations: Long-idling crop popups on hosts that sweep /tmp aggressively; Kubernetes pods with emptyDir tmp mounts restarted mid-edit; load-balanced servers where node A created the session dir and node B (no shared temp storage) serves the crop request.

Related errors


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