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

未關閉
#557 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 4 天內回覆

@Dx-Alz-xD 已經在處理了。

開始於 2026年11月11日。

  • #564 來自 @Dx-Alz-xD —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
mongodb, next.js, typescript
領域
api, backend

研究方向

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

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

主要語言
TypeScript
星號
23
分支
67
平均合併
2 天 17 小時
30 天內合併 PR
7

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

CodeChefVIT/papers-codechef 的其他 Issue

查看 CodeChefVIT/papers-codechef 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。