Return 404 for invalid or cross-family tag deletions#2470
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesTag deletion 404 fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
What
Tag::DeletionsControllerusedfind_byto look up both the tag and its replacement. A missing id or a tag from another family left@tagasnil, socreatecalledreplace_and_destroy!onniland raisedNoMethodError, returning an HTTP 500. The same flaw let an invalidreplacement_tag_idsilently passnilinto the deletion.This switches the lookups to
find, matching the existingCategory::DeletionsController, so out-of-scope ids now return a clean 404.Changes
findso missing or cross-family ids raiseRecordNotFound(404).present?andfind, keeping the "no replacement" case valid while rejecting invalid ids.tag_idand an invalidreplacement_tag_id.Why
The behavior now mirrors
Category::DeletionsController, keeping tag and category deletion consistent and ensuring family scoping returns 404 rather than leaking a server error.Testing
bin/rails test test/controllers/tag/deletions_controller_test.rbFixes #2469
Summary by CodeRabbit