Skip to content

feat(notes): enforce maximum title and content length limits with live character counters (fix #1048) - #152

Open
Pratyush-Panda-2006 wants to merge 1 commit into
niharika-mente:mainfrom
Pratyush-Panda-2006:fix-note-length-limits-issue-1048
Open

feat(notes): enforce maximum title and content length limits with live character counters (fix #1048)#152
Pratyush-Panda-2006 wants to merge 1 commit into
niharika-mente:mainfrom
Pratyush-Panda-2006:fix-note-length-limits-issue-1048

Conversation

@Pratyush-Panda-2006

@Pratyush-Panda-2006 Pratyush-Panda-2006 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

📌 Title

feat(notes): enforce maximum title and content length limits with live character counters

📝 Summary of Changes

  • Enforced maximum title (100 chars) and content (5000 chars) length limits in backend controller notesController.js.
  • Added maxLength properties and live character counters to CreatePage.jsx and NoteDetailPage.jsx.

Fixes #1048

Summary by CodeRabbit

  • New Features

    • Added live character counters to note creation and editing forms.
    • Enforced maximum lengths of 100 characters for titles and 5,000 characters for note content.
    • Added clear validation messages when limits are exceeded.
  • Bug Fixes

    • Prevented notes with overlong titles or content from being submitted.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Note length limits

Layer / File(s) Summary
Backend note length validation
backend/src/controllers/notesController.js
createNote and updateNote reject oversized titles and content with HTTP 400 responses.
Frontend length counters and limits
frontend/src/pages/CreatePage.jsx, frontend/src/pages/NoteDetailPage.jsx
The forms display live character counters and enforce maximum lengths for titles and content.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

  • niharika-mente/ThinkBoard#147 — Both PRs modify the note controllers and creation/detail pages, but address different validation and UI concerns.

Suggested reviewers: zaibamachhaliya

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: enforcing note length limits and adding live character counters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0faa6f2 and c6587a1.

📒 Files selected for processing (3)
  • backend/src/controllers/notesController.js
  • frontend/src/pages/CreatePage.jsx
  • frontend/src/pages/NoteDetailPage.jsx

Comment on lines +116 to +126
<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}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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”.

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