diced / zipline

A ShareX/file upload server that is easy to use, packed with features, and with an easy setup!
https://zipline.diced.sh/
MIT License
1.31k stars 128 forks source link

Bug: /api/auth/invite (DELETE) does not have error handling for PrismaClientKnownRequest errors #520

Closed cswimr closed 8 months ago

cswimr commented 8 months ago

What happened?

Title explains it, logs are below. This occurs if you attempt to delete an invite that doesn't exist. It should just return a status code of 404, not 500.

Version

upstream (ghcr.io/diced/zipline:trunk)

What browser(s) are you seeing the problem on?

No response

Zipline Logs

2023-12-22 17:24:02 zipline-zipline-1   | PrismaClientKnownRequestError: 
2023-12-22 17:24:02 zipline-zipline-1   | Invalid `prisma.invite.delete()` invocation:
2023-12-22 17:24:02 zipline-zipline-1   | 
2023-12-22 17:24:02 zipline-zipline-1   | 
2023-12-22 17:24:02 zipline-zipline-1   | An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.
2023-12-22 17:24:02 zipline-zipline-1   |     at fl.handleRequestError (/zipline/node_modules/@prisma/client/runtime/binary.js:187:6819)
2023-12-22 17:24:02 zipline-zipline-1   |     at fl.handleAndLogRequestError (/zipline/node_modules/@prisma/client/runtime/binary.js:187:6207)
2023-12-22 17:24:02 zipline-zipline-1   |     at fl.request (/zipline/node_modules/@prisma/client/runtime/binary.js:187:5927)
2023-12-22 17:24:02 zipline-zipline-1   |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-12-22 17:24:02 zipline-zipline-1   |     at async a (/zipline/node_modules/@prisma/client/runtime/binary.js:192:10035)
2023-12-22 17:24:02 zipline-zipline-1   |     at async c (/zipline/.next/server/pages/api/auth/invite.js:1:4151) {
2023-12-22 17:24:02 zipline-zipline-1   |   code: 'P2025',
2023-12-22 17:24:02 zipline-zipline-1   |   clientVersion: '5.6.0',
2023-12-22 17:24:02 zipline-zipline-1   |   meta: { cause: 'Record to delete does not exist.' }
2023-12-22 17:24:02 zipline-zipline-1   | }
2023-12-22 17:24:02 zipline-zipline-1   | 2023-12-22 10:24:02,557 PM info  [server::response] DELETE /api/auth/invite?code=2x4PFr -> 500

Browser Logs

No response

Additional Info

No response

diced commented 8 months ago

should be fixed https://github.com/diced/zipline/commit/70d48dd8c3f73e6c96fc60f31d2ddd67303e0a63