{"record":{"id":"c3d5b55e44714ed1","repo":"affaan-m/ECC","slug":"file-too-large-max-5mb","errorCode":null,"errorMessage":"File too large (max 5MB)","messagePattern":"File too large \\(max 5MB\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"skills/security-review/SKILL.md","lineNumber":83,"sourceCode":"  try {\n    const validated = CreateUserSchema.parse(input)\n    return await db.users.create(validated)\n  } catch (error) {\n    if (error instanceof z.ZodError) {\n      return { success: false, errors: error.issues }\n    }\n    throw error\n  }\n}\n```\n\n#### File Upload Validation\n```typescript\nfunction validateFileUpload(file: File) {\n  // Size check (5MB max)\n  const maxSize = 5 * 1024 * 1024\n  if (file.size > maxSize) {\n    throw new Error('File too large (max 5MB)')\n  }\n\n  // Type check\n  const allowedTypes = ['image/jpeg', 'image/png', 'image/gif']\n  if (!allowedTypes.includes(file.type)) {\n    throw new Error('Invalid file type')\n  }\n\n  // Extension check\n  const allowedExtensions = ['.jpg', '.jpeg', '.png', '.gif']\n  const extension = file.name.toLowerCase().match(/\\.[^.]+$/)?.[0]\n  if (!extension || !allowedExtensions.includes(extension)) {\n    throw new Error('Invalid file extension')\n  }\n\n  return true\n}\n```","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/affaan-m/ECC/blob/d8409a4b0813771235555e32e3d8046a73988bfa/skills/security-review/SKILL.md#L65-L101","documentation":"Illustrative file-upload validator from the security-review skill: the uploaded File's size exceeds the 5MB constant, so the guard throws before type or extension checks run. The oversized upload itself is the invalid input.","triggerScenarios":"Thrown at skills/security-review/SKILL.md:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reject server-side and show the limit in the upload UI","Configure the reverse proxy/body parser to enforce the same limit","Compress or resize images client-side before uploading"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d8409a4b0813771235555e32e3d8046a73988bfa","analyzedAt":"2026-08-26T12:15:34.022Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}