Skip to content

fix: return 204 instead of 500 for repeated module-issue deletes - #9910

Merged
dheeru0198 merged 1 commit into
previewfrom
fix/module-issue-destroy-missing
Sep 29, 2026
Merged

dheeru0198 merged 1 commit into
previewfrom
fix/module-issue-destroy-missing

Conversation

@pablohashescobar

@pablohashescobar pablohashescobar commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Description

Deleting a work item from a module when that link is already gone returned 500. ModuleIssueViewSet.destroy read module_issue.first().module.name, and first() is None on a repeated delete, which raised AttributeError.

  • Look the link up once with select_related("module").
  • If it is already gone, return 204 and skip the module.activity.deleted activity.
  • If it exists, remove it and record the activity with the module name, as before.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • DELETE /api/workspaces/{slug}/projects/{project_id}/modules/{module_id}/issues/{issue_id}/ when the work item is not in the module returns 204 and does not queue an activity.
  • The same delete when the link exists returns 204, removes the ModuleIssue row, and the activity payload includes the module name.
  • Deleting the same link a second time returns 204, not 500.
  • docker compose -f docker-compose-test.yml run --rm api-tests pytest plane/tests/contract/app/test_module_issue_destroy_app.py

References

  • No work item ID.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Deleting a module–issue link now succeeds whether or not the link exists. When a link is present, its deletion activity displays the correct module name.

- `module_issue.first()` returns None when the link is already gone, so
  reading `.module.name` raised AttributeError and the API returned 500.
- Look up the link once with select_related, and return 204 without
  queuing an activity if it doesn't exist.
- Add contract tests for deleting a missing link (204, no activity) and
  an existing link (removed, activity carries the module name).
Copilot AI balanced review requested due to automatic review settings September 29, 2026 07:40
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 7184250a-9e58-4399-acee-e95c644ac761

📥 Commits

Reviewing files that changed from the base of the PR and between c23728e and 4bbf812.

📒 Files selected for processing (2)
  • apps/api/plane/app/views/module/issue.py
  • apps/api/plane/tests/contract/app/test_module_issue_destroy_app.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The module–issue deletion endpoint now returns HTTP 204 when the association is missing. For an existing association, it uses the loaded module name in the deletion activity. Contract tests cover both cases.

Changes

Module–issue deletion

Layer / File(s) Summary
Deletion handling and contract tests
apps/api/plane/app/views/module/issue.py, apps/api/plane/tests/contract/app/test_module_issue_destroy_app.py
The endpoint returns HTTP 204 without scheduling activity when the association is missing. For an existing association, it uses the loaded module name in the activity and removes the link. Contract tests check both cases.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 4bbf8

Repeated deletion is expected to return 204 without creating activity. No merge-blocking risk is established; proceed with normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 4bbf8

The change makes repeated deletes succeed without creating a second activity. The existing access check and link scope remain in place, and no new security concern was established. Some downstream and failure behavior remains unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The observed change is confined to responses and activity for the addressed module–issue link. The absent-link branch performs no deletion or activity scheduling; the present-link deletion retains its workspace, project, module, and issue filters.

Trust Boundaries and Controls

  • observed — The unchanged role check precedes the new branch. Both present- and absent-link paths return 204, so the new status does not distinguish those two outcomes.

Resilience and Maintainability Implications

  • inferred — The guard improves sequential delete idempotency, but it does not make activity scheduling and deletion atomic. That limitation follows the existing operation order rather than a new trust-boundary change.
🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the repeated-delete failure, the code change, expected behavior, test scenarios, and change type. It includes all required template sections. Screenshots are not applicable, a…
Title check ✅ Passed The title clearly describes the main change: repeated module-issue deletes now return HTTP 204 instead of HTTP 500.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fix correctly addresses the failure and includes appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes idempotent module-issue deletion by returning 204 when the link no longer exists.

Changes:

  • Reuses one related-object lookup and skips activity creation for missing links.
  • Adds contract tests for existing and missing links.
File Description
apps/​api/​plane/​app/​views/​module/​issue.py Handles repeated deletion safely.
apps/​api/​plane/​tests/​contract/​app/​test_module_issue_destroy_app.py Covers deletion behavior and activity dispatch.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dheeru0198
dheeru0198 merged commit 4d7ea0e into preview Sep 29, 2026
19 of 20 checks passed
@dheeru0198
dheeru0198 deleted the fix/module-issue-destroy-missing branch September 29, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants