feat: auto-expand assignees in work item queries#80
feat: auto-expand assignees in work item queries#80Quentin-M wants to merge 1 commit intomakeplane:canaryfrom
Conversation
Always include 'assignees' in the expand parameter for get_work_item and list_work_items. This ensures callers receive UserLite objects with display names instead of bare UUIDs, making the API response immediately useful without a follow-up members lookup.
📝 WalkthroughWalkthroughModified work item retrieval functions to automatically ensure assignees are expanded in API responses. When the expand parameter is provided, ",assignees" is appended; otherwise, it defaults to "assignees" to consistently return UserLite objects for assignee data. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 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)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
plane_mcp/tools/work_items.py (1)
231-236: Factorexpandnormalization into a helper.This is the same logic as Lines 181-186, and the current
"assignees" not in expandtest is
substring-based rather than field-based. A shared helper that splits, strips, and rejoins the CSV
will avoid drift and false matches.Suggested refactor
+def _ensure_assignees_expanded(expand: str | None) -> str: + expanded_fields = [field.strip() for field in expand.split(",")] if expand else [] + if "assignees" not in expanded_fields: + expanded_fields.append("assignees") + return ",".join(expanded_fields) + @@ - # Always expand assignees to get UserLite objects instead of bare UUIDs. - if expand: - if "assignees" not in expand: - expand = f"{expand},assignees" - else: - expand = "assignees" + expand = _ensure_assignees_expanded(expand)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plane_mcp/tools/work_items.py` around lines 231 - 236, Extract the expand-normalization logic into a helper (e.g., normalize_expand_fields(expand: Optional[str], required_field: str) -> str) that: splits the CSV on ',', strips whitespace from each token, checks membership by exact token equality (not substring), returns required_field when expand is falsy, and otherwise returns the original tokens joined with ',' (appending required_field if missing). Replace the duplicated blocks that manipulate the expand variable (the occurrences that currently use "assignees" not in expand) with calls to this helper (passing "assignees" as required_field) so both sites use the same robust logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plane_mcp/tools/work_items.py`:
- Around line 181-186: The list_work_items() path currently forwards the expand
parameter unchanged so assignees remain bare UUIDs; update list_work_items() to
mirror the retrieve path's expansion logic: when expand is truthy and does not
already include "assignees" append ",assignees", otherwise set expand to
"assignees" so list responses return UserLite objects; adjust the code where
list_work_items() prepares or forwards the expand variable (the same expand
handling block used for retrieve_work_item) to ensure consistent behavior.
---
Nitpick comments:
In `@plane_mcp/tools/work_items.py`:
- Around line 231-236: Extract the expand-normalization logic into a helper
(e.g., normalize_expand_fields(expand: Optional[str], required_field: str) ->
str) that: splits the CSV on ',', strips whitespace from each token, checks
membership by exact token equality (not substring), returns required_field when
expand is falsy, and otherwise returns the original tokens joined with ','
(appending required_field if missing). Replace the duplicated blocks that
manipulate the expand variable (the occurrences that currently use "assignees"
not in expand) with calls to this helper (passing "assignees" as required_field)
so both sites use the same robust logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0611738a-fc36-40c2-b256-9b1fc7ad1d19
📒 Files selected for processing (1)
plane_mcp/tools/work_items.py
| # Always expand assignees to get UserLite objects instead of bare UUIDs. | ||
| if expand: | ||
| if "assignees" not in expand: | ||
| expand = f"{expand},assignees" | ||
| else: | ||
| expand = "assignees" |
There was a problem hiding this comment.
Apply the same assignee expansion to list_work_items().
This fixes the retrieve path, but list_work_items() still forwards expand unchanged on Lines
53-56. The list tool will therefore keep returning bare assignee UUIDs unless callers opt in,
which leaves list and retrieve responses inconsistent with the stated behavior.
Suggested fix
+def _ensure_assignees_expanded(expand: str | None) -> str:
+ expanded_fields = [field.strip() for field in expand.split(",")] if expand else []
+ if "assignees" not in expanded_fields:
+ expanded_fields.append("assignees")
+ return ",".join(expanded_fields)
+
`@mcp.tool`()
def list_work_items(
project_id: str,
cursor: str | None = None,
per_page: int | None = None,
@@
params = WorkItemQueryParams(
cursor=cursor,
per_page=per_page,
- expand=expand,
+ expand=_ensure_assignees_expanded(expand),
fields=fields,
order_by=order_by,
external_id=external_id,
external_source=external_source,
)
@@
- # Always expand assignees to get UserLite objects instead of bare UUIDs.
- if expand:
- if "assignees" not in expand:
- expand = f"{expand},assignees"
- else:
- expand = "assignees"
+ expand = _ensure_assignees_expanded(expand)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plane_mcp/tools/work_items.py` around lines 181 - 186, The list_work_items()
path currently forwards the expand parameter unchanged so assignees remain bare
UUIDs; update list_work_items() to mirror the retrieve path's expansion logic:
when expand is truthy and does not already include "assignees" append
",assignees", otherwise set expand to "assignees" so list responses return
UserLite objects; adjust the code where list_work_items() prepares or forwards
the expand variable (the same expand handling block used for retrieve_work_item)
to ensure consistent behavior.
Summary
assigneesin theexpandparameter forget_work_itemandlist_work_itemsUserLiteobjects with display names instead of bare UUIDsChanges
plane_mcp/tools/work_items.py: Added assignee expansion logic to bothget_work_itemandlist_work_itemsfunctions🤖 Generated with Claude Code
Summary by CodeRabbit