| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Plane v1.3.0 changed the API to return labels and assignees as UUID strings instead of expanded objects. WorkItemDetail typed these as list[Label] and list[UserLite] respectively, causing a Pydantic ValidationError on any retrieve_work_item call against a v1.3.0+ instance. Change both fields to list[str] | list[T] = [] so they accept either representation, and default to [] for sparse responses (consistent with WorkItemExpand and the fix in makeplane#28). Adds 8 unit tests covering: UUID strings, expanded objects, empty lists, omitted fields, and that name remains required.
📝 Walkthrough
WalkthroughThe WorkItemDetail model is updated to accept assignees and labels fields as either UUID strings or full objects, with both fields now optional and defaulting to empty lists. A comprehensive test suite validates backward compatibility with the new string-based input format and existing object-based inputs. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem🚥 Pre-merge checks | ✅ 3 ✅ Passed checks (3 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. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
There was a problem hiding this comment.
tests/unit/test_work_item_detail_types.py (1)🤖 Prompt for all review comments with AI agents58-92: Strengthen object-form tests with type assertions.
These two tests currently validate count only. Adding element-type checks will catch parser regressions where dict/object coercion changes unexpectedly.
Suggested test hardening🤖 Prompt for AI Agentsimport pytest from pydantic import ValidationError +from plane.models.labels import Label +from plane.models.users import UserLite from plane.models.work_items import WorkItemDetail @@ def test_labels_as_objects(self) -> None: @@ item = WorkItemDetail(**data) assert len(item.labels) == 1 + assert isinstance(item.labels[0], Label) @@ def test_assignees_as_objects(self) -> None: @@ item = WorkItemDetail(**data) assert len(item.assignees) == 1 + assert isinstance(item.assignees[0], UserLite)Verify each finding against the current code and only fix it if needed. In `@tests/unit/test_work_item_detail_types.py` around lines 58 - 92, Tests test_labels_as_objects and test_assignees_as_objects only assert lengths; strengthen them by asserting the parsed elements are proper model instances (not raw dicts) and expose expected attributes: for WorkItemDetail -> item.labels[0], assert it's not a dict (e.g., not isinstance(..., dict)) and has attributes like id and name/color; for item.assignees[0], assert it's not a dict and has id and display_name (and optional avatar/is_bot) to catch regressions where dicts are returned instead of parsed objects.
Verify each finding against the current code and only fix it if needed. Nitpick comments: In `@tests/unit/test_work_item_detail_types.py`: - Around line 58-92: Tests test_labels_as_objects and test_assignees_as_objects only assert lengths; strengthen them by asserting the parsed elements are proper model instances (not raw dicts) and expose expected attributes: for WorkItemDetail -> item.labels[0], assert it's not a dict (e.g., not isinstance(..., dict)) and has attributes like id and name/color; for item.assignees[0], assert it's not a dict and has id and display_name (and optional avatar/is_bot) to catch regressions where dicts are returned instead of parsed objects.
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0402f7cb-fa2f-4ed2-b315-c75be3cd46e3
📥 CommitsReviewing files that changed from the base of the PR and between d6c824d and 5fb4e25.
📒 Files selected for processing (2)
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Problem
Plane v1.3.0 changed the API to return labels and assignees as UUID strings instead of expanded objects, even on full (non-sparse) responses. WorkItemDetail typed both as required non-optional lists of objects:
This causes a ValidationError on every retrieve_work_item / retrieve_work_item_by_identifier call against a Plane v1.3.0+ instance:
Fix
Change both fields to accept either UUID strings or expanded objects, and default to [] for sparse responses (consistent with WorkItemExpand and the approach in #28):
Relation to #28
PR #28 fixes ValidationError when labels/assignees are absent from a sparse response. This PR fixes ValidationError when they are present as strings — a different code path, same field. The two fixes are complementary; combining them (union type + default []) handles all cases.
Tests
8 new unit tests in tests/unit/test_work_item_detail_types.py:
All 8 pass.
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests