Skip to content

fix: unreachable 404 check in DELETE /api/generate/[id]#232

Merged
SATYAM-PRATIBHAN merged 1 commit into
SATYAM-PRATIBHAN:mainfrom
soumojit-D48:fix/dead-404-check-delete-handler
May 27, 2026
Merged

fix: unreachable 404 check in DELETE /api/generate/[id]#232
SATYAM-PRATIBHAN merged 1 commit into
SATYAM-PRATIBHAN:mainfrom
soumojit-D48:fix/dead-404-check-delete-handler

Conversation

@soumojit-D48
Copy link
Copy Markdown
Contributor

Description

Fixes an unreachable 404 check in the DELETE handler of /api/generate/[id]. Prisma's .delete() throws a P2025 error when the record doesn't exist — it never returns null. The existing if (!generation) check after delete() was dead code, causing users to receive a 500 instead of a proper 404.

The fix replaces direct delete() with a findFirst() check first. If the generation is not found, we return 404 immediately. Only then do we call delete().

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Related Issues

Fixes #231

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have tested my changes locally

Requested Labels

GSSoC 2026 , gssoc:approved , level:beginner , quality:clean , type:refactor

@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2026

👷 Deploy request for arcmind-ai pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a75e6db

@soumojit-D48
Copy link
Copy Markdown
Contributor Author

@SATYAM-PRATIBHAN, Hi kindly check this PR and let me know, Thank U!!

@SATYAM-PRATIBHAN SATYAM-PRATIBHAN added gssoc:approved This issue or pull request already exists level:beginner Advance UI type:refactor labels May 27, 2026
@SATYAM-PRATIBHAN SATYAM-PRATIBHAN merged commit 431da20 into SATYAM-PRATIBHAN:main May 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved This issue or pull request already exists level:beginner Advance UI type:refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead 404 check in DELETE /api/generate/[id] — Prisma throws instead of returning null

2 participants