Skip to content

Conversation

@jezweb
Copy link

@jezweb jezweb commented Nov 8, 2025

Problem

The todo form says "PNG, JPG up to 5MB" but doesn't actually validate:

  • File size (users can upload gigabyte files)
  • File type (users can upload any file type)

This can cause:

  • Upload failures
  • Server errors
  • Wasted bandwidth
  • Poor user experience

Solution

Add client-side validation in handleImageChange:

  • Check file size ≤ 5MB
  • Check file type is PNG or JPG
  • Show toast error for invalid files
  • Reset file input on error

Benefits

  • ✅ Prevents large file uploads before they start
  • ✅ Clear error messages to users
  • ✅ Matches documented requirements
  • ✅ Better user experience

Testing

  • ✅ Tested with 6MB file - shows error
  • ✅ Tested with PDF file - shows error
  • ✅ Tested with valid 2MB PNG - works correctly

Changes

  • Line 7: Import toast
  • Lines 111-125: Add file validation logic

- Validate image files are under 5MB before upload
- Validate only PNG/JPG files are accepted
- Show toast error messages for validation failures
- Reset file input on validation error
- Prevents large file uploads that would fail
- Matches documented limits ("PNG, JPG up to 5MB")
@coderabbitai
Copy link

coderabbitai bot commented Nov 8, 2025

Warning

Rate limit exceeded

@jezweb has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a44687a and e5e4bb3.

📒 Files selected for processing (1)
  • src/modules/todos/components/todo-form.tsx (2 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

jezweb pushed a commit to jezweb/full-flare-stack that referenced this pull request Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant