{"record":{"id":"f597408f16808a1d","repo":"makeplane/plane","slug":"file-too-large-size-should-not-exceed-5-mb","errorCode":null,"errorMessage":"File too large. Size should not exceed 5 MB.","messagePattern":"File too large\\. Size should not exceed 5 MB\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"apps/api/plane/db/models/asset.py","lineNumber":28,"sourceCode":"from django.core.exceptions import ValidationError\nfrom django.db import models\n\n# Module import\nfrom plane.utils.path_validator import sanitize_filename\n\nfrom .base import BaseModel\n\n\ndef get_upload_path(instance, filename):\n    filename = sanitize_filename(filename) or uuid4().hex\n    if instance.workspace_id is not None:\n        return f\"{instance.workspace.id}/{uuid4().hex}-{filename}\"\n    return f\"user-{uuid4().hex}-{filename}\"\n\n\ndef file_size(value):\n    if value.size > settings.FILE_SIZE_LIMIT:\n        raise ValidationError(\"File too large. Size should not exceed 5 MB.\")\n\n\nclass FileAsset(BaseModel):\n    \"\"\"\n    A file asset.\n    \"\"\"\n\n    class EntityTypeContext(models.TextChoices):\n        ISSUE_ATTACHMENT = \"ISSUE_ATTACHMENT\"\n        ISSUE_DESCRIPTION = \"ISSUE_DESCRIPTION\"\n        COMMENT_DESCRIPTION = \"COMMENT_DESCRIPTION\"\n        PAGE_DESCRIPTION = \"PAGE_DESCRIPTION\"\n        USER_COVER = \"USER_COVER\"\n        USER_AVATAR = \"USER_AVATAR\"\n        WORKSPACE_LOGO = \"WORKSPACE_LOGO\"\n        PROJECT_COVER = \"PROJECT_COVER\"\n        DRAFT_ISSUE_ATTACHMENT = \"DRAFT_ISSUE_ATTACHMENT\"\n        DRAFT_ISSUE_DESCRIPTION = \"DRAFT_ISSUE_DESCRIPTION\"","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/db/models/asset.py#L10-L46","documentation":"Django ValidationError raised by the `file_size` validator attached to `FileAsset` fields when an uploaded file's byte size exceeds `settings.FILE_SIZE_LIMIT`. The default limit is 5242880 bytes (5 MiB) per common.py:353, set from the `FILE_SIZE_LIMIT` env var. The message hardcodes '5 MB' even though the real limit is configurable.","triggerScenarios":"Uploading a workspace logo, page/issue/comment description asset, or any FileAsset-bound file larger than `FILE_SIZE_LIMIT`. The validator fires during model full_clean / form/serializer validation when `value.size` is read from the stored upload.","commonSituations":"Default deployment where FILE_SIZE_LIMIT is unchanged (5 MiB) and a user uploads a high-res image or PDF; raising FILE_SIZE_LIMIT in env but the message still says '5 MB'; uploads that pass the presigned-URL size check (which clamps client size) but the actual stored object is larger.","solutions":["Reduce the file below `FILE_SIZE_LIMIT` bytes (default 5 MiB) before uploading.","Raise the limit in your environment: set `FILE_SIZE_LIMIT=<bytes>` (e.g. 10485760 for 10 MiB) and restart the API; remember DATA_UPLOAD_MAX_MEMORY_SIZE is bound to the same env var (common.py:371).","Compress/resize images or split large attachments before upload.","If surfacing to users, read `settings.FILE_SIZE_LIMIT` dynamically rather than trusting the hardcoded '5 MB' text."],"exampleFix":"# before (env)\nFILE_SIZE_LIMIT=5242880\n\n# after - allow 10 MiB\nFILE_SIZE_LIMIT=10485760","handlingStrategy":"validation","validationCode":"from django.conf import settings\n\ndef under_limit(uploaded_file) -> bool:\n    # mirrors asset.py:27 file_size validator\n    return getattr(uploaded_file, 'size', 0) <= settings.FILE_SIZE_LIMIT","typeGuard":null,"tryCatchPattern":"from django.core.exceptions import ValidationError\ntry:\n    asset.full_clean()\nexcept ValidationError as e:\n    if 'File too large' in str(e):\n        # surface the configured limit, not the hardcoded '5 MB'\n        return bad_request(f'Exceeds {settings.FILE_SIZE_LIMIT} bytes')","preventionTips":["Read settings.FILE_SIZE_LIMIT at runtime; do not trust the '5 MB' message text.","Check size client-side before upload and again server-side.","Remember FILE_SIZE_LIMIT also bounds DATA_UPLOAD_MAX_MEMORY_SIZE."],"tags":["file-upload","validation","django-models","file-size"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}