You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(api): return 400 when transferring work items to a cycle that does not exist - #10391
transfer_cycle_issues loaded the target cycle with .first() and then read new_cycle.end_date, so a new_cycle_id that isn't a cycle of the project (deleted, or from another project) raised AttributeError and returned a 500 from both the web app and the public API transfer endpoints. It now returns "Target cycle not found", next to the existing "Source cycle not found" check, which both endpoints already answer with a 400.
Type of Change
Bug fix (non-breaking change which fixes an issue)
Test Scenarios
apps/api/plane/tests/contract/app/test_cycle_transfer_missing_cycle_app.py: a random id and a cycle of another project both give a 400 with "Target cycle not found", and the source cycle's progress snapshot is left untouched. Both fail on preview with a 500.
Fixed cycle transfers to unavailable or unrelated destination cycles. These requests now return a clear error instead of causing an unexpected failure.
No actionable comments were generated in the recent review.
Walkthrough
The transfer utility now returns a failure response when the destination cycle lookup finds no cycle. Contract tests cover nonexistent and cross-project target IDs. They assert HTTP 400, and the nonexistent-target test checks the error message and unchanged source-cycle progress snapshot.
Changes: Cycle transfer validation
Layer / File(s)
Summary
Target cycle check and contract coverage apps/api/plane/utils/cycle_transfer_issues.py, apps/api/plane/tests/contract/app/test_cycle_transfer_missing_cycle_app.py
The transfer utility returns a failure response when no destination cycle matches the lookup. Contract tests assert HTTP 400 for nonexistent and cross-project targets. The nonexistent-target test also checks the error message and source cycle’s progress snapshot.
Transferring work items to a missing or out-of-project cycle now returns a clear 400 error instead of a server error. The change is small and contained, and I found no remaining merge risk.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: transfers to a nonexistent target cycle now return HTTP 400 instead of failing. It matches the code change that adds a "Target cycle not found" check in transfer_cycle…
Description check
The description follows the template. It explains the bug and the fix in detail, and marks the Bug fix type. It describes the test scenarios and links the issue (Fixes #10390). The template's Screensh…
Linked Issues check
Issue #10390 requires that a target cycle ID that is not a cycle of the project does not cause a 500. The reviewed head of apps/api/plane/utils/cycle_transfer_issues.py now queries the target with Cyc…
Out of Scope Changes check
The changes cover the reported defect. The utility change adds a single guard for the target cycle with a specific error message. The new contract test file exercises the two reproduction cases and ch…
Full details: Title check
Explanation
The title names the main change: transfers to a nonexistent target cycle now return HTTP 400 instead of failing. It matches the code change that adds a "Target cycle not found" check in transfer_cycle_issues and the contract tests for that case. The title uses the conventional fix(api) prefix and is specific.
Full details: Description check
Explanation
The description follows the template. It explains the bug and the fix in detail, and marks the Bug fix type. It describes the test scenarios and links the issue (Fixes #10390). The template's Screenshots section is absent, and the Type of Change list marks only Bug fix. The screenshots section is optional because the change is backend-only, so this gap does not block the check.
Full details: Linked Issues check
Explanation
Issue #10390 requires that a target cycle ID that is not a cycle of the project does not cause a 500. The reviewed head of apps/api/plane/utils/cycle_transfer_issues.py now queries the target with Cycle.objects.filter(workspace__slug=slug, project_id=project_id, pk=new_cycle_id).first(). It returns {"success": False, "error": "Target cycle not found"} when the result is None, before the code reads new_cycle.end_date. This covers both a deleted cycle and a cycle from another project, because the filter is scoped to the workspace and project. The shared function serves both the web app and the public API endpoints. The PR adds contract tests in apps/api/plane/tests/contract/app/test_cycle_transfer_missing_cycle_app.py for a random ID and a cross-project cycle, asserting HTTP 400, the message, and an unchanged source progress snapshot. The base revision of the diff could not be read, so the before-state is taken from the PR summary. The endpoint mapping from success False to HTTP 400 was not inspected directly; the PR description states that the existing Source cycle not found path already returns 400 through the same mechanism.
Full details: Out of Scope Changes check
Explanation
The changes cover the reported defect. The utility change adds a single guard for the target cycle with a specific error message. The new contract test file exercises the two reproduction cases and checks the source cycle snapshot is not modified. No unrelated functional changes were identified in the summary. The base-side diff could not be read, so this verdict relies on the PR summary and the reviewed head file content.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
transfer_cycle_issuesloaded the target cycle with.first()and then readnew_cycle.end_date, so anew_cycle_idthat isn't a cycle of the project (deleted, or from another project) raisedAttributeErrorand returned a 500 from both the web app and the public API transfer endpoints. It now returns "Target cycle not found", next to the existing "Source cycle not found" check, which both endpoints already answer with a 400.Type of Change
Test Scenarios
apps/api/plane/tests/contract/app/test_cycle_transfer_missing_cycle_app.py: a random id and a cycle of another project both give a 400 with "Target cycle not found", and the source cycle's progress snapshot is left untouched. Both fail onpreviewwith a 500.References
Fixes #10390
Summary by CodeRabbit