Skip to content

feat: auto-expand assignees in work item queries#80

Open
Quentin-M wants to merge 1 commit intomakeplane:canaryfrom
Quentin-M:feat/auto-expand-assignees
Open

feat: auto-expand assignees in work item queries#80
Quentin-M wants to merge 1 commit intomakeplane:canaryfrom
Quentin-M:feat/auto-expand-assignees

Conversation

@Quentin-M
Copy link

@Quentin-M Quentin-M commented Mar 10, 2026

Summary

  • Always include assignees in the expand parameter for get_work_item and list_work_items
  • Returns UserLite objects with display names instead of bare UUIDs
  • Avoids the need for a follow-up members API call to resolve assignee names

Changes

  • plane_mcp/tools/work_items.py: Added assignee expansion logic to both get_work_item and list_work_items functions

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Work item retrieval operations now consistently return complete assignee information, ensuring user details are always available when fetching work items.

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.
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

Modified 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

Cohort / File(s) Summary
Assignee Expansion Logic
plane_mcp/tools/work_items.py
Added automatic assignee expansion to retrieve_work_item and retrieve_work_item_by_identifier functions. Control flow now appends ",assignees" to existing expand parameters or defaults to "assignees" when not provided, ensuring UserLite objects are always included in responses.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A tweak, so neat, in work items grand,
Assignees now always at hand!
No more forgotten souls in the fray,
They'll expand every single day,
Hopping along in expanded display! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: automatically expanding assignees in work item queries to return UserLite objects instead of UUIDs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
plane_mcp/tools/work_items.py (1)

231-236: Factor expand normalization into a helper.

This is the same logic as Lines 181-186, and the current "assignees" not in expand test 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

📥 Commits

Reviewing files that changed from the base of the PR and between e18a2b4 and e9aec26.

📒 Files selected for processing (1)
  • plane_mcp/tools/work_items.py

Comment on lines +181 to +186
# 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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

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.

1 participant