Skip to content

[GIT-221] fix(cycle): guard against no end_date when archiving cycle#9200

Open
Rahulcheryala wants to merge 1 commit into
previewfrom
git-221/fix-archive-cycle-no-end-date
Open

[GIT-221] fix(cycle): guard against no end_date when archiving cycle#9200
Rahulcheryala wants to merge 1 commit into
previewfrom
git-221/fix-archive-cycle-no-end-date

Conversation

@Rahulcheryala
Copy link
Copy Markdown
Contributor

@Rahulcheryala Rahulcheryala commented Jun 3, 2026

Description

Archiving a cycle with no end date caused a TypeError because end_date was compared directly to timezone.now() without a null check. Added an explicit None guard so cycles without an end date are treated as incomplete and return a 400 instead of crashing with a 500.

cycle.end_date >= timezone.now() raises TypeError: '>=' not supported between instances of 'NoneType' and 'datetime.datetime' when end_date is not set.

Added cycle.end_date is None check before the comparison in both archive endpoints:

  • plane/api/views/cycle.py
  • `plane/app/views/cycle/archive.py

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots and Media (if applicable)

Before:
image

After:
image

Test Scenarios

Create a cycle without start and end dates and make API call to archive the cycle, expected response status code is 400 and message is

{
    "error": "Only completed cycles can be archived"
}

References

Fixes #9169

Summary by CodeRabbit

  • Bug Fixes
    • Updated cycle archiving validation to correctly handle cycles based on their end dates. Cycles can now only be archived when they have a past end date set.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6163e10-3a66-4f2e-a454-cae9622beb90

📥 Commits

Reviewing files that changed from the base of the PR and between b1c78fe and 628b910.

📒 Files selected for processing (2)
  • apps/api/plane/api/views/cycle.py
  • apps/api/plane/app/views/cycle/archive.py

📝 Walkthrough

Walkthrough

Two cycle archive endpoints are updated to safely validate whether a cycle can be archived when its end_date is None or in the future, fixing a TypeError that occurred when comparing None to datetime values.

Changes

Cycle Archive End Date Validation

Layer / File(s) Summary
Archive eligibility checks for cycles without end dates
apps/api/plane/api/views/cycle.py, apps/api/plane/app/views/cycle/archive.py
Both the API endpoint at line 766 and the app view endpoint at line 590 now validate that cycles have a past end_date before allowing archival. The guards properly handle None end_date values to prevent TypeError comparisons.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A cycle with no end in sight,
Now archives without a TypeError's bite!
Two guards stand firm, None values in place,
The rabbit hops freely through archival space. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Title check ✅ Passed The title clearly and specifically describes the main change: adding a null check for end_date when archiving cycles to prevent errors.
Description check ✅ Passed The description includes all required template sections: detailed explanation of the bug, type of change marked as bug fix, screenshots showing before/after, test scenarios, and references to the linked issue.
Linked Issues check ✅ Passed The PR successfully addresses the core objective from issue #9169: it adds None guard checks before end_date comparison to prevent TypeError and returns a 400 error instead of crashing with 500.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the TypeError when archiving cycles with no end_date; no unrelated modifications detected in the two affected files.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch git-221/fix-archive-cycle-no-end-date

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.

@makeplane
Copy link
Copy Markdown

makeplane Bot commented Jun 3, 2026

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

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.

Archiving a Cycle with No End Date Crashes with TypeError

2 participants