/api/user-papers and /api/upload return 500 for malformed requests

Đang mở
#557 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

@Dx-Alz-xD đang làm issue này rồi.

Từ ngày 11/11/2026.

  • #564 của @Dx-Alz-xD — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
mongodb, next.js, typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Start with the route handlers at src/app/api/user-papers/route.ts and src/app/api/upload/route.ts, then check how their inputs reach Mongoose and arrayBuffer(). Add request validation that returns 400 for malformed input, including the subject limit and the single-file rule when isPdf is true. Done when the reproduction requests return 400 with clear messages and valid requests still work.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug
These routes dont check the shape of their input so bad requests become 500 instead of 400

To Reproduce

  1. POST /api/user-papers with body {} -> 500 "Failed to fetch papers."
  2. POST /api/upload with form field files=hello (text, not a file) -> 500 "Failed to upload papers".

Expected behavior
400 with a clear message. zod is already a dependency, so a small schema per route would work, an array of strings with a max length for user papers, and File instances (exactly one when isPdf) for upload

Ngôn ngữ chính
TypeScript
Star
23
Fork
67
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeChefVIT/papers-codechef

Tất cả issue của CodeChefVIT/papers-codechef

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.