/api/paper-by-id returns 500 instead of 404 for a paper that doesn't exist

Aberta
#554 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 4 dias

@Dx-Alz-xD já está trabalhando nisso.

Desde 11/11/2026.

  • #561 de @Dx-Alz-xD — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
typescript

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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"

https://github.com/CodeChefVIT/papers-codechef/blob/6e3aa1152a34c7eb46d36f58294dffd9ff3b3c7b/src/lib/services/paper.ts#L43

To Reproduce

  1. Request /api/paper-by-id/<a valid ObjectId that isn't in the database>, e.g. /api/paper-by-id/000000000000000000000000
  2. 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

Linguagem predominante
TypeScript
Estrelas
23
Forks
67
Merge médio
2d 17h
PRs com merge (30d)
7

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de CodeChefVIT/papers-codechef

Todas as issues de CodeChefVIT/papers-codechef

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.