Skip to content

fix(api): enforce classroom text field limits - #667

Open
tosind wants to merge 1 commit into
freeCodeCamp:mainfrom
tosind:fix/classroom-field-limits
Open

tosind wants to merge 1 commit into
freeCodeCamp:mainfrom
tosind:fix/classroom-field-limits

Conversation

@tosind

@tosind tosind commented Oct 21, 2026

Copy link
Copy Markdown

Authenticated requests can currently save classroom names and descriptions beyond the limits enforced by the form. Both create and edit now return HTTP 400 for invalid text before writing to the database, using the same 100-character name and 500-character description limits as the modal.

The limits live in a shared utility. Creation requires a nonempty string name; partial edits still allow omitted fields, and descriptions remain optional and nullable. Existing authentication and teacher ownership checks remain in place.

Validation:

  • pnpm run lint passed (existing repository warnings remain).
  • pnpm test: 355 tests passed.
  • Playwright: the seven existing smoke tests and the new API integration test passed against a seeded local Postgres database. The new test sends oversized requests directly, accepts exact-limit text, updates the description alone, and deletes its test classroom.
  • pnpm run build --webpack passed.

Related to #640, section 2: classroom name and description validation. This PR addresses that item only.

Checklist:

  • I have read and followed the contribution guidelines.
  • This pull request targets main.
  • I have run pnpm run lint and pnpm test locally.
  • I have tested these changes in the browser with pnpm run develop --webpack.

AI assistance was used for implementation and review; all checks listed above were run locally.

@tosind
tosind requested a review from a team as a code owner October 21, 2026 19:27
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