chore: add page-to-work-item attachment methods to SDK#36
chore: add page-to-work-item attachment methods to SDK#36akhil-vamshi-konam wants to merge 3 commits into
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds work-item page linking to the Plane Python SDK. It introduces a new ChangesWork Item Page Linking
Sequence Diagram(s)sequenceDiagram
participant Client
participant WorkItemPages
participant API
Client->>WorkItemPages: list(workspace_slug, project_id, work_item_id)
WorkItemPages->>API: GET /workspaces/.../pages
API-->>WorkItemPages: PaginatedWorkItemPageResponse
Client->>WorkItemPages: create(workspace_slug, project_id, work_item_id, CreateWorkItemPage)
WorkItemPages->>API: POST /workspaces/.../pages
API-->>WorkItemPages: WorkItemPage
Client->>WorkItemPages: retrieve(workspace_slug, project_id, work_item_id, work_item_page_id)
WorkItemPages->>API: GET /workspaces/.../pages/{id}
API-->>WorkItemPages: WorkItemPage
Client->>WorkItemPages: delete(workspace_slug, project_id, work_item_id, work_item_page_id)
WorkItemPages->>API: DELETE /workspaces/.../pages/{id}
API-->>WorkItemPages: (no response)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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 |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plane/api/pages.py`:
- Around line 24-25: The endpoint URL strings for the pages list calls are
missing a trailing slash, causing redirects; update the calls that invoke
self._get to use f"{workspace_slug}/pages/" (and the other similar call around
the block that returns PaginatedPageResponse.model_validate) so the URL ends
with '/' per convention; search for uses of self._get with the "pages" path in
this file and add the trailing slash to each occurrence.
In `@plane/api/work_items/pages.py`:
- Around line 20-21: The list method currently accepts a raw dict parameter
`params: dict | None` (in the `list` function returning
`PaginatedWorkItemPageResponse`); change it to accept a Pydantic query DTO
(e.g., a new or existing QueryModel type) and before calling `_get` serialize it
with `query_model.model_dump(exclude_none=True)` instead of passing a raw dict,
then validate the response with
`PaginatedWorkItemPageResponse.model_validate()`; apply the same change (replace
raw dict params with the DTO + model_dump serialization and response
model_validate) to the other affected resource methods referenced around lines
30-33.
- Around line 31-33: The WorkItemPages endpoints are missing required trailing
slashes; update each endpoint string in the WorkItemPages resource to end with a
"/" (e.g. change
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/pages" to
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/pages/"), and
make the same change for the three other similar endpoint strings in the
WorkItemPages class so all requests follow the
`{base_path}/api/v1{resource_base_path}/{endpoint}/` convention.
In `@tests/unit/test_work_item_pages.py`:
- Around line 31-40: The page fixture creates a workspace page via
client.pages.create_workspace_page but never deletes it; convert the fixture to
a teardown-style (use yield) so after tests run you call the pages deletion API
(e.g., client.pages.delete_workspace_page or the appropriate client.pages.delete
method) with the created page's identifier to remove the page; update the
fixture named page to return (yield) the created CreatePage result and then call
the deletion in the finally/after-yield block to avoid leaking test pages.
- Around line 26-29: Replace the bare "except Exception: pass" around the
cleanup call to client.work_items.delete(workspace_slug, project.id, wi.id) with
targeted exception handling: import PlaneError from plane.errors and catch only
PlaneError (e.g., "except PlaneError: pass" or better "except PlaneError as e:
log.warning(...)") for expected SDK/cleanup failures, and allow all other
exceptions to propagate so unexpected errors fail the test; apply the same
change for the other cleanup calls at the same pattern (the other
client.work_items.delete and similar blocks).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d8a5716a-deaa-4f76-a6a7-6bf003cd21e7
📒 Files selected for processing (5)
plane/api/pages.pyplane/api/work_items/base.pyplane/api/work_items/pages.pyplane/models/work_item_pages.pytests/unit/test_work_item_pages.py
Description
WorkItemPagessub-resource to the SDK to support linking pages to work items via the public API (/work-items/{id}/pages/).list_workspace_pagesandlist_project_pagesmethods to thePagesresource.New files:
plane/api/work_items/pages.py—WorkItemPagessub-resource withlist,retrieve,create,deleteplane/models/work_item_pages.py—WorkItemPage,WorkItemPageLite,CreateWorkItemPage,PaginatedWorkItemPageResponseType of Change
Test Scenarios
tests/unit/test_work_item_pages.py— covers create, list, retrieve, and delete of work item page links against a real APISummary by CodeRabbit
New Features
Tests