Skip to content

bug: /api/notify endpoint lacks rate limiting, Zod validation, and MONGODB_URI graceful degradation #2067

@Tranquil666

Description

@Tranquil666

Description

The /api/notify POST endpoint has several gaps compared to other API routes in the project:

Problems

  1. No rate limiting — Unlike /api/track-user which uses trackUserRateLimiter, the notify endpoint has no rate limiting, allowing spam of email registrations.

  2. No Zod validation — Uses manual if (!username || !email) validation instead of Zod schemas, which is inconsistent with all other API routes that use Zod.

  3. No MONGODB_URI graceful degradation — When MONGODB_URI is unset, it will crash with an unhandled error. Compare with /api/track-user which handles this explicitly.

  4. No GitHub username format validation — The username field is not validated against GITHUB_USERNAME_REGEX.

  5. Missing from middleware matcher — The endpoint is not listed in the middleware matcher (middleware.ts lines 57-63), so it also bypasses the global per-IP rate limiter.

Expected behavior

  • Add rate limiting consistent with other endpoints
  • Migrate to Zod schema validation using githubParamsSchema or a similar schema
  • Add graceful handling when MONGODB_URI is not configured
  • Validate GitHub username format
  • Add the route to the middleware matcher

Files

  • app/api/notify/route.ts
  • middleware.ts (matcher config)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions