feat(notes): enforce maximum title and content length limits with live character counters (fix #1048) - #152
Conversation
…e character counters (fix #1048)
📝 WalkthroughWalkthroughThe PR adds maximum lengths of 100 characters for titles and 5,000 characters for content. Backend create and update handlers return HTTP 400 for oversized values. Create and detail forms show live counters and enforce the limits. ChangesNote length limits
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/pages/NoteDetailPage.jsx`:
- Around line 116-126: Update handleSave in NoteDetailPage to validate the
trimmed title and content lengths before sending the update request, including
legacy values exceeding their limits, and surface a clear validation message
instead of making a failing request. Preserve the existing maxLength inputs and,
in the request error path, display error.response?.data?.message when available
rather than only “Failed to update note”.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f9b118a7-978d-441b-ad21-3bfd120c4f90
📒 Files selected for processing (3)
backend/src/controllers/notesController.jsfrontend/src/pages/CreatePage.jsxfrontend/src/pages/NoteDetailPage.jsx
| <div className="flex justify-between items-center mb-2"> | ||
| <label className="block text-sm font-medium text-gray-700 dark:text-gray-300"> | ||
| Title | ||
| </label> | ||
| <span className="text-xs text-gray-500 dark:text-gray-400"> | ||
| {(note.title || "").length} / 100 | ||
| </span> | ||
| </div> | ||
| <input | ||
| type="text" | ||
| maxLength={100} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Show validation feedback for legacy oversized notes.
maxLength limits new edits, but it does not shorten values loaded into note. Because backend/src/models/Note.js has no length constraints, an existing oversized note can display 101 / 100, fail on save, and show only "Failed to update note". Surface error.response?.data?.message or validate the trimmed values in handleSave before sending the request.
Also applies to: 136-145
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@frontend/src/pages/NoteDetailPage.jsx` around lines 116 - 126, Update
handleSave in NoteDetailPage to validate the trimmed title and content lengths
before sending the update request, including legacy values exceeding their
limits, and surface a clear validation message instead of making a failing
request. Preserve the existing maxLength inputs and, in the request error path,
display error.response?.data?.message when available rather than only “Failed to
update note”.
📌 Title
feat(notes): enforce maximum title and content length limits with live character counters
📝 Summary of Changes
notesController.js.maxLengthproperties and live character counters toCreatePage.jsxandNoteDetailPage.jsx.Fixes #1048
Summary by CodeRabbit
New Features
Bug Fixes