{"record":{"id":"c797ef722b6736da","repo":"Leantime/leantime","slug":"1003-c797ef","errorCode":"1003","errorMessage":"File exceeds maximum allowed size","messagePattern":"File exceeds maximum allowed size","errorType":"validation","errorClass":"Leantime\\Core\\Files\\Exceptions\\FileValidationException","httpStatus":null,"severity":"error","filePath":"app/Domain/Files/Services/Files.php","lineNumber":156,"sourceCode":"\n            $this->authorize(FilesPermissions::UPLOAD, $targetProjectId);\n        }\n        // Non-project modules (user avatar, private, ...) have no project context and preserve prior\n        // behavior; their flows pin moduleId server-side (e.g. ProfileImage forces the session user's id).\n\n        try {\n            // Validate file type with the enhanced validator\n            $symfonyFile = new UploadedFile(\n                $file['file']['tmp_name'],\n                $file['file']['name'],\n                $file['file']['type'],\n                $file['file']['error'],\n                true\n            );\n\n            // Validate file size before processing\n            if ($file['file']['size'] > FileManager::getMaximumFileUploadSize()) {\n                throw new FileValidationException('File exceeds maximum allowed size', FileValidationException::FILE_TOO_LARGE);\n            }\n        } catch (FileValidationException $e) {\n            Log::warning('File validation failed: '.$e->getMessage());\n\n            return $e->getUserMessage();\n        }\n\n        try {\n            // Create a UploadedFile instance\n            $symfonyFile = new UploadedFile(\n                $file['file']['tmp_name'],\n                $file['file']['name'],\n                $file['file']['type'],\n                $file['file']['error'],\n                (bool) config('app.debug')\n            );\n\n            $leantimeFile = $this->fileManager->upload($symfonyFile, $disk);","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/Leantime/leantime/blob/9a9f49f1008f4782b30f6723c54228f4f992e636/app/Domain/Files/Services/Files.php#L138-L174","documentation":"After constructing the UploadedFile, upload() compares $file['file']['size'] against FileManager::getMaximumFileUploadSize() (the effective PHP limit derived from ini settings) and throws FileValidationException with code 1003 (FILE_TOO_LARGE) for oversize files. Like the other FileValidationException paths, it is caught inside the method and returned as a user-facing message string — the caller sees a string return, not an exception.","triggerScenarios":"Uploading an attachment larger than the effective limit (the smallest of upload_max_filesize / post_max_size); raising the webserver or nginx client_max_body_size but not the PHP ini values; one request carrying several files whose combined size exceeds post_max_size.","commonSituations":"Default PHP limits (often 2M/8M) vs modern attachment sizes; Docker/managed-hosting images with small defaults; reverse-proxy body limits capping uploads before PHP sees them.","solutions":["Upload a smaller file (compress images, split archives)","Raise the limits together: upload_max_filesize AND post_max_size in php.ini (plus any proxy client_max_body_size), then restart PHP-FPM","Check the return value: is_string($result) means validation failed and the string is the message to show the user"],"exampleFix":"# before (php.ini)\nupload_max_filesize = 2M\npost_max_size = 8M\n\n# after\nupload_max_filesize = 64M\npost_max_size = 68M","handlingStrategy":"validation","validationCode":"$max = \\Leantime\\Core\\Files\\FileManager::getMaximumFileUploadSize();\nif ($file['file']['size'] > $max) {\n    // upload() would return the FILE_TOO_LARGE message string\n    return ['error' => \"File exceeds the {$max} byte server limit\"];\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check file size in the browser before POSTing (File.size against the server limit exposed to the client)","Raise upload_max_filesize AND post_max_size (and proxy body limits) together when limits are too small","Like other FileValidationException paths, oversize files come back as a returned string — branch on is_string($result)"],"tags":["files","upload","file-size","php-ini","validation"],"backgroundTag":"file-exceeds-upload-max-size","analyzedSha":"9a9f49f1008f4782b30f6723c54228f4f992e636","analyzedAt":"2026-08-21T02:37:38.966Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}