Skip to content

Improve /api/request: deduplicate requests, add input validation #550

Open

Description

@Rithish-2914

Current state: Basic rate limiting exists in middleware (5 req/15 min).

Remaining issues:
No deduplication - PaperRequest.create() blindly inserts duplicates for same subject + exam + slot + year
No enum validation on exam field before DB insert - invalid values throw a 500 instead of 400

Activity

  1. Dx-Alz-xD commented on Nov 11, 2026

    @Dx-Alz-xD
    Contributor

    /api/request is already rate limited and src/middleware.ts matches /api/request and allows 5 requests per 15 minutes (paperRequestRatelimit in src/lib/utils/ratelimit.ts), the same as /api/upload. So I think this can be closed

  2. Rithish-2914 commented on Nov 12, 2026

    @Rithish-2914
    ContributorAuthor

    Thanks for checking them out !!
    The basic rate limiting is already in place via paperRequestRatelimit in src/middleware.ts (5 requests per 15 minutes). However, keeping this open to address a few remaining gaps:
    Duplicate requests - no deduplication on subject + exam + slot + year, so the same paper can flood the DB with identical requests from different users
    Missing input validation - exam has an enum in the schema but the route doesn't validate it before the DB call, causing a 500 instead of a clean 400

    So we would check if we could work on these and ill update the issue

  3. changed the title [-]Missing Rate Limiting on Paper Requests (/api/request)[/-] [+]Improve /api/request: deduplicate requests, add input validation[/+] on Nov 12, 2026
  4. Dx-Alz-xD commented on Nov 12, 2026

    @Dx-Alz-xD
    Contributor

    go thru this once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions