fix: not found handling for bookings and Prisma record lookups#29583
fix: not found handling for bookings and Prisma record lookups#29583ChayanDass wants to merge 1 commit into
Conversation
|
Welcome to Cal.diy, @ChayanDass! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
43abd88 to
e870ac8
Compare
|
@bandhan-majumder , Please take a look whenever you are free! |
bandhan-majumder
left a comment
There was a problem hiding this comment.
left some comments and since this PR (#28614) is inactive, I would rather focus on the current one. Also please take care of this comment: #28621 (review) if u have not already!! Also can u add some test cases so the fix can be verified??
e870ac8 to
397ffca
Compare
|
@bandhan-majumder , Ready for review, please check! |
this fix is correct but it has to be handled in the trpc handler. This comment I mentioned here, suggests that only. The first PR which was opened claiming to fix this issue, go through the conversation. It also has the same fix on the prisma level but not on the trpc level. Hope that helps! |
Signed-off-by: Chayan Das <daschayan8837@gmail.com>
397ffca to
ce4fe19
Compare
What does this PR do?
Fixes #28614
This PR improves handling of not-found scenarios by returning proper HTTP 404 responses instead of exposing Prisma errors to API consumers.
Changes
Booking deletion/cancellation
getBookingToDelete()previously usedprisma.booking.findUniqueOrThrow(), which could surface an unhandled Prisma error when a booking did not exist.This has been replaced with
findUnique()and an explicit null check.Before:
NotFoundErrorcould propagate to clientsAfter:
Example:
{ "message": "Booking does not exist" }Visual Demo
Before
After
Mandatory Tasks
How should this be tested?
Setup
Run Cal.diy locally with a valid development environment and database.
Reproduction
Expected Results
Existing booking
Returns a successful cancellation response.
Missing booking
Returns HTTP 404:
{ "message": "Booking with uid non-existent-uid-12345 does not exist" }Prisma not-found errors
Return HTTP 404:
{ "message": "The requested record was not found." }No Prisma stack traces or internal error details should be exposed.
Checklist