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

Ouverte
#554 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 4 jours

@Dx-Alz-xD y travaille déjà.

Depuis le 11/11/2026.

  • #561 par @Dx-Alz-xD — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
typescript

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
TypeScript
Étoiles
23
Forks
67
Merge moyen
2 j 17 h
PR mergées (30 j)
7

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de CodeChefVIT/papers-codechef

Toutes les issues de CodeChefVIT/papers-codechef

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.