Skip to content

fix: enforce 100-character max length on goal title (closes #384#463

Closed
MehtabSandhu11 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
MehtabSandhu11:fix/goal-title-max-length-384
Closed

fix: enforce 100-character max length on goal title (closes #384#463
MehtabSandhu11 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
MehtabSandhu11:fix/goal-title-max-length-384

Conversation

@MehtabSandhu11
Copy link
Copy Markdown

@MehtabSandhu11 MehtabSandhu11 commented May 20, 2026

Summary

Neither the frontend input nor the POST /api/goals endpoint validated the length of the goal title. A very long title would be stored in the database and overflow the progress bar card layout, breaking the UI.

Changes

src/app/api/goals/route.ts

  • Added a server-side guard in the POST handler: returns 400 with a descriptive error if title.trim().length > 100

src/components/GoalTracker.tsx

  • Added maxLength={100} to the title <input> as a browser-level hard stop
  • Added a live character counter ({n}/100) that turns red at 90+ characters to warn the user before they hit the limit
  • Added inline error message below the input when the limit is exceeded
  • Added client-side validation in handleCreate() to block submission without a network round-trip
  • Updated the submit button's disabled condition to also block when a title error is present
  • Added aria-describedby on the input pointing to the hint/counter element for accessibility

Behaviour

Scenario Result
Title ≤ 100 chars Works as before
Title 91–100 chars Counter turns red, form still submits
Title > 100 chars Inline error shown, submit blocked client-side
Direct API call with title > 100 chars 400 Bad Request with error message

Testing

  • Typed a title over 100 characters — counter turns red and submit is disabled
  • Submitted via form at exactly 100 characters — succeeds
  • Sent a POST request directly to /api/goals with a 101-character title — returns 400
  • npm run lint && npm run type-check pass with no new errors

Please apply the appropriate labels so that I can get the GSSoC points.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

@MehtabSandhu11 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels May 20, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Closing — the server-side validation here is a subset of what PR #469 already implements more thoroughly (full type checks, bounds, error handling). #469 has been merged. If you want to contribute the client-side character counter from this PR, please open a fresh PR against the updated main branch.

@MehtabSandhu11 MehtabSandhu11 deleted the fix/goal-title-max-length-384 branch May 21, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants