Skip to content

chore: add page-to-work-item attachment methods to SDK#36

Open
akhil-vamshi-konam wants to merge 3 commits into
mainfrom
chore-page-to-work-item-attachment
Open

chore: add page-to-work-item attachment methods to SDK#36
akhil-vamshi-konam wants to merge 3 commits into
mainfrom
chore-page-to-work-item-attachment

Conversation

@akhil-vamshi-konam
Copy link
Copy Markdown

@akhil-vamshi-konam akhil-vamshi-konam commented May 18, 2026

Description

  • Adds WorkItemPages sub-resource to the SDK to support linking pages to work items via the public API (/work-items/{id}/pages/).
  • Adds list_workspace_pages and list_project_pages methods to the Pages resource.

New files:

  • plane/api/work_items/pages.pyWorkItemPages sub-resource with list, retrieve, create, delete
  • plane/models/work_item_pages.pyWorkItemPage, WorkItemPageLite, CreateWorkItemPage, PaginatedWorkItemPageResponse

Type of Change

  • Feature (non-breaking change which adds functionality)

Test Scenarios

  • tests/unit/test_work_item_pages.py — covers create, list, retrieve, and delete of work item page links against a real API

Summary by CodeRabbit

  • New Features

    • Work items now support page attachments with complete lifecycle management: create page links, view all attached pages, and remove links as needed
    • Added functionality to list and browse workspace and project pages
  • Tests

    • Added test coverage for work item page management operations

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@akhil-vamshi-konam has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 18 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c3420a1-4f44-439d-a423-8796e1cf0a4e

📥 Commits

Reviewing files that changed from the base of the PR and between 85b2800 and 7c55f54.

📒 Files selected for processing (1)
  • plane/api/work_items/pages.py
📝 Walkthrough

Walkthrough

This PR adds work-item page linking to the Plane Python SDK. It introduces a new WorkItemPages resource with full CRUD operations, defines Pydantic data models for the link entity, enhances the Pages API with pagination-aware list methods, integrates the resource into the WorkItems client, and includes comprehensive integration tests.

Changes

Work Item Page Linking

Layer / File(s) Summary
Work Item Page Data Models
plane/models/work_item_pages.py
Four Pydantic models define the contracts: WorkItemPageLite for nested page metadata, WorkItemPage for the link entity, CreateWorkItemPage for POST payloads, and PaginatedWorkItemPageResponse for list responses with configuration to allow extra fields and populate by name.
Pages API List Methods
plane/api/pages.py
Two methods (list_workspace_pages, list_project_pages) added to the Pages resource to retrieve paginated page lists with optional query parameters; unused Mapping import removed.
WorkItemPages CRUD Resource
plane/api/work_items/pages.py
New WorkItemPages resource class extends BaseResource with four methods: list() returns paginated page links for a work item, retrieve() gets a single link by ID, create() POSTs a new link via CreateWorkItemPage serialization, and delete() removes a link; all responses validated against models.
WorkItems Sub-Resource Integration
plane/api/work_items/base.py
WorkItemPages imported and initialized as self.pages in WorkItems.__init__, making the resource accessible alongside existing sub-resources.
Integration Tests
tests/unit/test_work_item_pages.py
Test suite exercises all CRUD operations via PlaneClient: fixtures create temporary work items and pages, then tests verify create (with cleanup), list (confirming created link appears), retrieve (by ID), and delete (confirming link no longer lists) operations.

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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit bounds through pages new,
Work-item links now breaking through,
Models shaped, resources wired,
CRUD ops tested, tests admired,
Five files dance in harmony true! 🐰📄

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change—adding page-to-work-item attachment methods to the SDK—matching the PR's core objective of implementing WorkItemPages functionality.
Docstring Coverage ✅ Passed Docstring coverage is 82.35% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore-page-to-work-item-attachment

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
Copy Markdown

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6e5389f and 85b2800.

📒 Files selected for processing (5)
  • plane/api/pages.py
  • plane/api/work_items/base.py
  • plane/api/work_items/pages.py
  • plane/models/work_item_pages.py
  • tests/unit/test_work_item_pages.py

Comment thread plane/api/pages.py
Comment thread plane/api/work_items/pages.py Outdated
Comment thread plane/api/work_items/pages.py
Comment thread tests/unit/test_work_item_pages.py
Comment thread tests/unit/test_work_item_pages.py
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