/api/user-papers and /api/upload return 500 for malformed requests
維護者通常 4 天內回覆
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- mongodb, next.js, typescript
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- TypeScript
- 星號
- 23
- 分支
- 67
- 平均合併
- 2 天 17 小時
- 30 天內合併 PR
- 7
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
CodeChefVIT/papers-codechef 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
CodeChefVIT/papers-codechef#577 ·
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
CodeChefVIT/papers-codechef#552 · 1 則留言 · 1 個 reaction ·
維護者通常 4 天內回覆
-
/api/upcoming-papers Throws 404 When No Exams are Active可能已有人在做 @Dx-Alz-xD 於 16 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
CodeChefVIT/papers-codechef#549 · 1 個 reaction ·
維護者通常 4 天內回覆
-
難度 3/5 1-2 天 新手友好度 69/100
CodeChefVIT/papers-codechef#576 ·
維護者通常 4 天內回覆
-
難度 3/5 1-2 天 新手友好度 64/100
CodeChefVIT/papers-codechef#575 ·
維護者通常 4 天內回覆
查看 CodeChefVIT/papers-codechef 的全部 Issue
相似的 Issue
-
good first issue help wanted
難度 2/5 1 小時以內 新手友好度 86/100
Intelligenza-Umana/intelligenza-umana-web#16 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
open-webui/open-webui#35184 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
danielmiessler/LifeOS#3001 ·
維護者通常 5 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆