fix: filter out soft-deleted states from API endpoints#8840
fix: filter out soft-deleted states from API endpoints#8840KanteshMurade wants to merge 2 commits intomakeplane:previewfrom
Conversation
- Add deleted_at__isnull=True filter to StateListCreateAPIEndpoint.get_queryset() - Add deleted_at__isnull=True filter to StateDetailAPIEndpoint.get_queryset() - Prevents soft-deleted states from reappearing in UI after navigation - Fixes makeplane#8829
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/api/plane/api/views/state.py`:
- Line 57: The added .filter(deleted_at__isnull=True) calls are redundant
because State.objects uses StateManager which inherits SoftDeletionManager and
already applies that condition in get_queryset(); remove the explicit
.filter(deleted_at__isnull=True) occurrences (the ones added around the query
using State.objects) to avoid no-op duplication, and instead audit other query
paths that may bypass State.objects (e.g., direct State._default_manager, raw
queries, or explicit QuerySet.from_model calls) if deleted records are still
appearing; search for usages of .filter(deleted_at__isnull=True) in this module
and delete the redundant filters, keeping queries built with State.objects so
the manager-level soft-delete behavior remains authoritative.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 77490cbc-7d73-48f7-962c-24d724abca94
📒 Files selected for processing (1)
apps/api/plane/api/views/state.py
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Updated PR description and clarified scope. Ready for review. |
Fixes #8829 (via issue endpoint filtering)
Problem
Soft-deleted states were reappearing in the UI after navigation.
Although states were correctly soft-deleted in the database (
deleted_atset), API responses were still returning them, causing the frontend to repopulate deleted states.Root Cause
The issue was initially suspected in the state API endpoints. However,
State.objectsalready excludes soft-deleted records via the SoftDeletionManager.The actual root cause was that issues referencing soft-deleted states were still being returned in the issue API responses.
Solution
.filter(deleted_at__isnull=True)from state endpointsstate__deleted_at__isnull=Trueissue_queryset) for consistencyEndpoint Clarification
Although the issue mentions state endpoints, the fix is applied in issue endpoints because they return state data indirectly through issue relationships.
Scope
This change intentionally updates the issue endpoint (
IssueListEndpoint) to ensure soft-deleted states are excluded from all API responses.Type of Change
Test Scenarios
Screenshots
N/A
Result