fix: accept unexpanded id lists for WorkItemDetail assignees/labels#46
fix: accept unexpanded id lists for WorkItemDetail assignees/labels#46hstern wants to merge 1 commit into
Conversation
WorkItemDetail typed `assignees: list[UserLite]` and `labels: list[Label]`,
but the Plane API returns these relations as bare UUID strings unless the
request expands them (`expand=assignees,labels`). Retrieving any assigned or
labelled work item without that expand therefore raised:
pydantic_core.ValidationError: ... validation errors for WorkItemDetail
assignees.0 Input should be a valid dictionary or instance of UserLite
labels.0 Input should be a valid dictionary or instance of Label
Widen both to `list[str] | list[UserLite]` / `list[str] | list[Label]`,
matching the tolerance `WorkItemDetail.state` (`str | StateLite`) and the
whole `WorkItemExpand` model already grant. Adds pure model-validation unit
tests covering the unexpanded, expanded, and default-empty shapes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR updates ChangesWorkItemDetail flexible relations schema and validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Problem
WorkItemDetailtypes its relations strictly:But the Plane API returns
assigneesandlabelsas bare UUID strings unless the request explicitly expands them (expand=assignees,labels). So retrieving any assigned or labelled work item without that expand raises:This makes a plain
work_items.retrieve(...)(noexpand) fail on real data — e.g. it surfaces throughplane-mcp-server'sretrieve_work_item_*tools against a self-hosted (CE) instance, where the default serializer returns the unexpanded shape.Fix
Widen both relations to accept either shape:
This mirrors the tolerance the same model already grants
state(str | StateLite) and that the siblingWorkItemExpandmodel already uses forassignees/labels. No behavior change for callers who do expand — those still validate intoUserLite/Labelobjects.Tests
Adds
tests/unit/test_work_item_models.py— pure model-validation tests (no HTTP) covering the unexpanded (bare-ID), expanded (nested-object), and default-empty shapes. The unexpanded case fails onmainand passes with this change; the full unit suite stays green.Summary by CodeRabbit
Refactor
Tests