affaan-m/ECC · error

File too large (max 5MB)

Error message

File too large (max 5MB)

What it means

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.

Source

Thrown at skills/security-review/SKILL.md:83

  try {
    const validated = CreateUserSchema.parse(input)
    return await db.users.create(validated)
  } catch (error) {
    if (error instanceof z.ZodError) {
      return { success: false, errors: error.issues }
    }
    throw error
  }
}
```

#### File Upload Validation
```typescript
function validateFileUpload(file: File) {
  // Size check (5MB max)
  const maxSize = 5 * 1024 * 1024
  if (file.size > maxSize) {
    throw new Error('File too large (max 5MB)')
  }

  // Type check
  const allowedTypes = ['image/jpeg', 'image/png', 'image/gif']
  if (!allowedTypes.includes(file.type)) {
    throw new Error('Invalid file type')
  }

  // Extension check
  const allowedExtensions = ['.jpg', '.jpeg', '.png', '.gif']
  const extension = file.name.toLowerCase().match(/\.[^.]+$/)?.[0]
  if (!extension || !allowedExtensions.includes(extension)) {
    throw new Error('Invalid file extension')
  }

  return true
}
```

View on GitHub (pinned to d8409a4b08)

Solutions

  1. Reject server-side and show the limit in the upload UI
  2. Configure the reverse proxy/body parser to enforce the same limit
  3. Compress or resize images client-side before uploading
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at skills/security-review/SKILL.md:83 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of affaan-m/ECC@d8409a4b08 (2026-08-26). Data as JSON: /api/errors/c3d5b55e44714ed1. Report an issue: GitHub.