Repository navigation
fix: serialize issue history before merging activities and comments - #9899
Conversation
Covers the merged activity/comment history endpoint, which previously crashed with a 500 (`TypeError: 'IssueActivity' object is not subscriptable`) when sorting raw model instances by `created_at` instead of dict keys.
|
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 configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe issue history response now sorts serialized activities and comments together. A contract test checks that the endpoint returns both record types in ascending ChangesIssue history response
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The issue history endpoint now returns activities and comments together in creation-time order. No actionable merge-blocking risk remains after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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.
Copilot review overview
🟡 Changes recommended
Adjust the contract test so it fails when merged results are not actually sorted.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes issue-history requests without activity_type by serializing activities and comments before merging and sorting.
Changes:
- Serialize both querysets before sorting.
- Add contract coverage for merged history responses.
| File | Summary |
|---|---|
apps/api/plane/tests/contract/app/test_issue_history_app.py |
Adds merged-history response and ordering coverage; the test should ensure the two sources require reordering. |
apps/api/plane/app/views/issue/activity.py |
Serializes activities and comments before merging and sorting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| IssueActivity.objects.create( | ||
| issue=issue, project=project, workspace=workspace, actor=create_user, verb="created", field="state" | ||
| ) | ||
| IssueComment.objects.create( | ||
| issue=issue, project=project, workspace=workspace, actor=create_user, comment_html="<p>hi</p>" | ||
| ) |
…akeplane#9899) Covers the merged activity/comment history endpoint, which previously crashed with a 500 (`TypeError: 'IssueActivity' object is not subscriptable`) when sorting raw model instances by `created_at` instead of dict keys. (cherry picked from commit c23728e)

Description
When
IssueActivityEndpointis called withoutactivity_type, it merges issue activities and comments into one list sorted bycreated_at. The sort ran on raw model instances withinstance["created_at"], so every request failed withTypeError: 'IssueActivity' object is not subscriptableand returned a 500.IssueActivitySerializerandIssueCommentSerializer) beforechain/sorted, so the sort key works on dicts. The response shape now matches the single-type branches.created_atorder.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
GET /api/workspaces/<slug>/projects/<project_id>/issues/<issue_id>/history/with noactivity_typereturns 200 with activities and comments interleaved increated_atorder.?activity_type=issue-propertyand?activity_type=issue-commentstill return only activities or only comments.?created_at__gt=<timestamp>withoutactivity_typereturns only newer items, merged and sorted.docker compose -f docker-compose-test.yml run --rm api-tests pytest plane/tests/contract/app/test_issue_history_app.pyReferences
🤖 Generated with Claude Code
Summary by CodeRabbit