{"record":{"id":"6af4699375f6aeaf","repo":"octobercms/october","slug":"the-image-editing-session-is-not-found","errorCode":null,"errorMessage":"The image editing session is not found.","messagePattern":"The image editing session is not found\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/media/widgets/MediaManager.php","lineNumber":1937,"sourceCode":"        $selectionParams = ['x', 'y', 'w', 'h'];\n\n        foreach ($selectionParams as $paramName) {\n            if (!array_key_exists($paramName, $selectionData)) {\n                throw new SystemException('Invalid selection data.');\n            }\n\n            if (!is_numeric($selectionData[$paramName])) {\n                throw new SystemException('Invalid selection data.');\n            }\n\n            $selectionData[$paramName] = (int) $selectionData[$paramName];\n        }\n\n        $sessionDirectoryPath = $this->getCropSessionDirPath($cropSessionKey);\n        $fullSessionDirectoryPath = temp_path($sessionDirectoryPath);\n\n        if (!File::isDirectory($fullSessionDirectoryPath)) {\n            throw new SystemException('The image editing session is not found.');\n        }\n\n        // Find the image on the disk and resize it\n        $imagePath = $fullSessionDirectoryPath.'/'.$fileName;\n        if (!File::isFile($imagePath)) {\n            throw new SystemException('The image is not found on the disk.');\n        }\n\n        if (!$this->validateFileType($originalFileName)) {\n            throw new ApplicationException(Lang::get('backend::lang.media.type_blocked'));\n        }\n\n        $extension = pathinfo($originalFileName, PATHINFO_EXTENSION);\n\n        $targetImageName = basename($originalFileName, '.'.$extension).'-'\n            .$selectionData['x'].'-'\n            .$selectionData['y'].'-'\n            .$selectionData['w'].'-'","sourceCodeStart":1919,"sourceCodeEnd":1955,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/media/widgets/MediaManager.php#L1919-L1955","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Close and reopen the crop popup to start a fresh crop session (new key, re-staged original).","Use shared, persistent storage for the temp directory in multi-server setups (configure the CMS temp path to a mounted volume).","Exclude the app temp path from tmp-reaper/cron cleanup jobs and container ephemeral mounts."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Client-side: on session-not-found, transparently restart the crop flow\nif (response.error && /editing session is not found/.test(response.error)) {\n    return startNewCropSession(path); // reopen popup, get fresh key\n}","typeGuard":null,"tryCatchPattern":"try {\n    $this->cropImage($src, $selection, $key, $path);\n} catch (\\System\\Classes\\SystemException $e) {\n    if (strpos($e->getMessage(), 'editing session is not found') !== false) {\n        $key = str_random(); // start over: stage again, then retry once\n        $this->getImageUrl($path, $key, null);\n        return $this->cropImage($src, $selection, $key, $path);\n    }\n    throw $e;\n}","preventionTips":["Point the CMS temp directory at persistent shared storage in clustered setups.","Keep crop popup lifetime short relative to your tmp cleanup interval.","Handle this error in the UI as 'session expired, reopening' rather than a hard failure."],"tags":["media-manager","crop","session","temp-files","cleanup"],"backgroundTag":"temp-session-missing","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}