/api/user-papers and /api/upload return 500 for malformed requests
Maintainer thường phản hồi trong vòng 4 ngày
Đá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
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
/api/user-paperscasts the body straight toStoredSubjectsand passes it to$in, abody that isnt an array of strings (e.g.{}or"x") makes Mongoose throw, which becomes a 500, theres also no cap on how many subjects can be sent
https://github.com/CodeChefVIT/papers-codechef/blob/6e3aa1152a34c7eb46d36f58294dffd9ff3b3c7b/src/app/api/user-papers/route.ts#L9/api/uploadcasts everyfilesentry toFile. A text value infilesfails atarrayBuffer()which becomes a 500, w/isPdf=true, every file after the first is silently ignored instead of rejected
https://github.com/CodeChefVIT/papers-codechef/blob/6e3aa1152a34c7eb46d36f58294dffd9ff3b3c7b/src/app/api/upload/route.ts#L11
To Reproduce
POST /api/user-paperswith body{}-> 500 "Failed to fetch papers."POST /api/uploadwith form fieldfiles=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
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CodeChefVIT/papers-codechef
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CodeChefVIT/papers-codechef#577 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CodeChefVIT/papers-codechef#552 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 4 ngày
-
/api/upcoming-papers Throws 404 When No Exams are ActiveCó thể đã có người làm @Dx-Alz-xD đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CodeChefVIT/papers-codechef#549 · 1 reaction ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 69/100
CodeChefVIT/papers-codechef#576 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
CodeChefVIT/papers-codechef#575 ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của CodeChefVIT/papers-codechef
Issue tương tự
-
good first issue help wanted
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 86/100
Intelligenza-Umana/intelligenza-umana-web#16 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
open-webui/open-webui#35184 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
danielmiessler/LifeOS#3001 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày