flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Backend] Map Prisma P2025 RecordNotFound errors to 404 Not Found in error.middleware.ts

Open blurbeast opened this issue 1 month ago • 8 comments

Overview

In backend/src/middleware/error.middleware.ts, unhandled Prisma P2025 errors (thrown when update or delete targets a non-existent record) currently fall through to the generic 500 Internal Server Error handler.

Problem

  • Clients requesting an update or deletion on a non-existent resource receive a 500 status code instead of a semantic 404 Not Found.

Proposed Changes

  1. Detect Prisma known request errors with code P2025 (and P2002 unique constraint conflicts) in backend/src/middleware/error.middleware.ts.
  2. Map P2025 to 404 Not Found and P2002 to 409 Conflict with structured JSON error responses.

Acceptance Criteria

  • [ ] P2025 errors return HTTP 404 with a clean message and no internal database stack trace.
  • [ ] P2002 errors return HTTP 409 with conflict details.
  • [ ] Unit tests added for error.middleware.ts.

blurbeast avatar Oct 18 '26 05:10 blurbeast

@Favouratambi has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hi maintainer, I'd love to work on this issue. Assign so we will get to work

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Favouratambi to this issue.

Favouratambi avatar Oct 18 '26 14:10 Favouratambi

@DeeMyth has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Good day maintainer I have gone through the requirement of this issue and I can definitely solve it Please assign it to me

ℹ️ Repo Maintainers: To accept this application, review their application or assign @DeeMyth to this issue.

DeeMyth avatar Oct 18 '26 14:10 DeeMyth

@DonaldXoftDev has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Can I take this on? I can deliver real quick!

ℹ️ Repo Maintainers: To accept this application, review their application or assign @DonaldXoftDev to this issue.

DonaldXoftDev avatar Oct 18 '26 14:10 DonaldXoftDev

@Johnsource-hub has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Please Maintainer, assign this issue to me. Thank you so much

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Johnsource-hub to this issue.

Johnsource-hub avatar Oct 18 '26 14:10 Johnsource-hub

@DooseWayo has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Can I work on this task?

ℹ️ Repo Maintainers: To accept this application, review their application or assign @DooseWayo to this issue.

DooseWayo avatar Oct 18 '26 14:10 DooseWayo

@Yilkash has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Can i work on this?

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Yilkash to this issue.

Yilkash avatar Oct 18 '26 14:10 Yilkash

Congratulations, @DooseWayo! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

🧑‍💻 @DooseWayo: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Oct 18 '26 14:10 drips-wave[bot]

This issue has been completed by @DooseWayo as part of the Stellar Wave Program's 10th Wave 🥳

😎 @DooseWayo: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Oct 18 '26 16:10 drips-wave[bot]