/api/paper-by-id returns 500 instead of 404 for a paper that doesn't exist
维护者通常 4 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
Read src/lib/services/paper.ts at the linked getPaperById code and inspect the /api/paper-by-id route plus @/lib/utils/error for the existing error handling pattern. Verify the behavior for a valid ObjectId with no matching paper; done means the endpoint returns 404 with “Paper not found” and the paper page can distinguish that from a server error. Pull request #561 is already open for this issue.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
getPaperById throws a plain Error("Paper not found") (with a // 404 comment) and the route catches every error and returns 500 "Failed to fetch paper"
To Reproduce
- Request
/api/paper-by-id/<a valid ObjectId that isn't in the database>, e.g./api/paper-by-id/000000000000000000000000 - The response is 500 "Failed to fetch paper"
Expected behavior
404 "Paper not found". CustomError and customErrorHandler from @/lib/utils/error (added in #436) already do this. Throwing new CustomError("Paper not found", 404) and using customErrorHandler in the route would fix it and the paper page could then tell "not found" apart from a server error
- 主要语言
- 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 天内回复