Skip to content

fix : return 404 instead of 403 when deleting a non-existent repository#2478

Open
tmdeveloper007 wants to merge 1 commit into
nisshchayarathi:mainfrom
tmdeveloper007:fix/2470-delete-403-to-404
Open

fix : return 404 instead of 403 when deleting a non-existent repository#2478
tmdeveloper007 wants to merge 1 commit into
nisshchayarathi:mainfrom
tmdeveloper007:fix/2470-delete-403-to-404

Conversation

@tmdeveloper007

@tmdeveloper007 tmdeveloper007 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

The DELETE handler returned HTTP 403 when deleteRepository() throws Repository not found. This is semantically incorrect — a 403 indicates forbidden access to an existing resource, whereas the resource does not exist, so HTTP 404 is correct.

Changes

  • app/api/repositories/[id]/route.ts: Changed status code from 403 to 404 in the DELETE handler when the repository is not found.

Impact

Clients can now correctly distinguish between "access denied" and "resource does not exist" responses.

Closes #2470

Summary by CodeRabbit

  • Bug Fixes
    • Updated the repository deletion response so “Repository not found” now returns a more appropriate 404 Not Found status instead of 403 Forbidden.
    • The user-facing error message remains unchanged.

The DELETE handler was returning HTTP 403 when deleteRepository() throws
'Repository not found'. This is semantically incorrect — a 403 indicates
forbidden access to an existing resource, whereas the resource does not
exist, so HTTP 404 is the correct status.

Closes nisshchayarathi#2470
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@tmdeveloper007 is attempting to deploy a commit to the Nisshchaya's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the gssoc:spam GSSoC: Spam contribution label Jun 24, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GSSoC Quality Check Failed — PR #2478

Hi @tmdeveloper007! 👋 Your PR has been flagged by our automated GSSoC quality check.

Issues found:

  • 📏 Trivially small change — Only 2 line(s) changed in 1 file. Changes this small are almost never meaningful contributions. Make sure your PR solves a real issue.

✅ How to fix this

  1. Read the issues listed above carefully
  2. Edit your PR title and description to address them
  3. Make sure your PR is linked to an open issue using closes #<issue-number>
  4. Make sure your changes are meaningful and solve a real problem

Once you've fixed these, a maintainer will review and remove the flag. If you believe this is a mistake, please comment below. 🙏

GSSoC'26 automation · Maintainer: @nisshchayarathi

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d3437eeb-be38-4e30-8a77-310781c5254a

📥 Commits

Reviewing files that changed from the base of the PR and between cd4e69b and 26b0c53.

📒 Files selected for processing (1)
  • app/api/repositories/[id]/route.ts

📝 Walkthrough

Walkthrough

In the DELETE /api/repositories/:id handler, the catch block's special case for error.message === "Repository not found" now returns HTTP 404 instead of 403. The response body and security headers are unchanged.

Changes

DELETE Handler Status Code Fix

Layer / File(s) Summary
Return 404 for not-found repository
app/api/repositories/[id]/route.ts
The catch block that matches "Repository not found" now responds with status 404 instead of 403, while keeping the same error body and security headers.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • nisshchayarathi/gitverse-nextjs#1555: Directly overlaps with this PR — both modify the same error.message === "Repository not found" branch in the DELETE handler of app/api/repositories/[id]/route.ts to adjust the returned HTTP status code.

Suggested labels

bug

🐇 A repo not found should cry out "four-oh-four!"
Not "four-oh-three" — that's a permission snore.
The status was wrong, a bug in disguise,
One digit corrected, the truth now replies.
Hoppity-fix! The REST spec is right! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: returning 404 instead of 403 for missing repositories.
Linked Issues check ✅ Passed The change matches issue #2470 by returning HTTP 404 when deleteRepository reports "Repository not found".
Out of Scope Changes check ✅ Passed The PR appears limited to the requested status-code fix in the DELETE repository handler with no unrelated changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:spam GSSoC: Spam contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DELETE /api/repositories/[id] returns 403 for not-found instead of 404

1 participant