Skip to content

feat: add dependency and custom relation sub-resources#50

Merged
Prashant-Surya merged 7 commits into
mainfrom
chore-custom-relations
Jun 17, 2026
Merged

feat: add dependency and custom relation sub-resources#50
Prashant-Surya merged 7 commits into
mainfrom
chore-custom-relations

Conversation

@akhil-vamshi-konam

@akhil-vamshi-konam akhil-vamshi-konam commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description:

Summary

Adds two new sub-resources on WorkItems to support the dedicated dependency and custom-relation endpoints introduced in the API:

  • client.work_items.dependencies — list, create, remove across all six directions (blocking / blocked_by / start_before / start_after / finish_before / finish_after)
  • client.work_items.custom_relations — list, create, remove using workspace-level relation definitions with outward/inward directionality

New models (plane/models/work_items.py)

  • DependencyTypeEnum — literal union of the six dependency directions
  • WorkItemWithRelationType — work item enriched with a relation_type label
  • WorkItemDependencyResponse — grouped response from GET relation-dependencies/
  • CreateWorkItemDependency / RemoveWorkItemDependency
  • CreateWorkItemCustomRelation / RemoveWorkItemCustomRelation

New API resources

  • WorkItemDependencies — hits /relation-dependencies/ and /relation-dependencies/remove/
  • WorkItemCustomRelations — hits /work-item-relations/ and /work-item-relations/remove/

Summary by CodeRabbit

  • New Features
    • Added work item dependency management (list, create, remove) with support for multiple relationship directions.
    • Added custom work item relations management (list, create, remove) and exposed it through the work-item API.
    • Extended work item type creation/update with an optional level field.
  • Bug Fixes
    • Updated work item search to use the search query parameter.
    • Work item relation definitions listing now returns paginated results (cursor + per-page).
  • Tests
    • Added unit tests covering dependency and custom relation endpoints, including creation, listing, and removal.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5034a4c-7db3-4e86-8454-ad76a12e0b78

📥 Commits

Reviewing files that changed from the base of the PR and between a5b47ab and db1b471.

📒 Files selected for processing (2)
  • plane/api/work_items/base.py
  • plane/models/work_items.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • plane/api/work_items/base.py
  • plane/models/work_items.py

📝 Walkthrough

Walkthrough

Adds WorkItemDependencies and WorkItemCustomRelations API client classes with list, create, and remove methods. New Pydantic models define request/response shapes for both relation types. Both clients are wired into WorkItems.__init__. An optional level field is added to work item type request models. Updates WorkItemRelationDefinitions.list() to support pagination via per_page and cursor parameters. Integration tests cover dependency and custom relation endpoints with fixtures. The WorkItems.search() method parameter key is updated from q to search.

Changes

Work Item Dependencies and Custom Relations

Layer / File(s) Summary
Relation and dependency data models
plane/models/work_items.py, plane/models/work_item_types.py
Adds DependencyTypeEnum literal type for six dependency directions; introduces WorkItemWithRelationType, WorkItemDependencyResponse, and four request/response models (CreateWorkItemDependency, RemoveWorkItemDependency, CreateWorkItemCustomRelation, RemoveWorkItemCustomRelation); adds optional level field to CreateWorkItemType and UpdateWorkItemType.
Paginated relation definitions response and updated list endpoint
plane/models/work_item_relation_definitions.py, plane/api/work_item_relation_definitions.py
Introduces PaginatedWorkItemRelationDefinitionResponse Pydantic model; updates WorkItemRelationDefinitions.list() to accept optional per_page and cursor parameters, build pagination query params, and return paginated response instead of plain list.
WorkItemDependencies and WorkItemCustomRelations API clients
plane/api/work_items/dependencies.py, plane/api/work_items/custom_relations.py
Implements WorkItemDependencies with list(), create(), and remove() methods for dependency relations; implements WorkItemCustomRelations with same three methods for definition-based custom relations; both use model_dump(exclude_none=True) for requests and model_validate() for responses.
WorkItems resource wiring and search parameter update
plane/api/work_items/base.py
Imports and instantiates WorkItemDependencies and WorkItemCustomRelations as sub-resources on WorkItems; updates WorkItems.search() to use search parameter key instead of q.
Integration tests and test infrastructure
tests/unit/test_work_item_relations.py, pyproject.toml
Adds dev extra with pytest and pytest-dependency to pyproject.toml; defines class-scoped fixtures creating two work items and custom relation definition with graceful teardown; TestWorkItemDependencies covers empty listing, creation, bidirectional listing, removal, and all relation_type values; TestWorkItemCustomRelations covers empty listing, outward/inward creation and listing, bidirectional removal, and HttpError on invalid definition.

Sequence Diagram(s)

sequenceDiagram
  participant Client as PlaneClient
  participant WorkItems
  participant Deps as WorkItemDependencies
  participant CRel as WorkItemCustomRelations
  participant API as Plane HTTP API

  rect rgba(100, 149, 237, 0.5)
    note over Client,API: Dependency creation and listing
    Client->>WorkItems: work_items.dependencies.create(slug, project_id, item_id, data)
    WorkItems->>Deps: create(slug, project_id, item_id, data)
    Deps->>API: POST /workspaces/{slug}/projects/{project_id}/issues/{item_id}/issue-relations/
    API-->>Deps: [{work_item, relation_type}, ...]
    Deps-->>Client: list[WorkItemWithRelationType]
  end

  rect rgba(144, 238, 144, 0.5)
    note over Client,API: Custom relation listing and creation
    Client->>WorkItems: work_items.custom_relations.list(slug, project_id, item_id)
    WorkItems->>CRel: list(slug, project_id, item_id)
    CRel->>API: GET /workspaces/{slug}/projects/{project_id}/issues/{item_id}/issue-relation/
    API-->>CRel: {outward_label: [...], inward_label: [...]}
    CRel-->>Client: dict[str, list[WorkItemWithRelationType]]
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • makeplane/plane-python-sdk#39: Both PRs touch plane/api/work_item_relation_definitions.py, specifically the WorkItemRelationDefinitions.list() implementation; this PR extends it with pagination parameters and response handling.

Suggested reviewers

  • sriramveeraghanta
  • dheeru0198
  • Prashant-Surya

Poem

🐇 Hop hop, dependencies now blocking the way,
Custom relations in label arrays at play,
List them, create them, remove with a bound,
Pagination scrolls through the whole hopping ground.
Six directions of flow, all tested with care,
Relations dance freely through Plane's open air! 🌿

🚥 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 'feat: add dependency and custom relation sub-resources' directly and clearly describes the main changes—adding two new sub-resources (dependencies and custom_relations) to the WorkItems API.
Docstring Coverage ✅ Passed Docstring coverage is 89.29% 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore-custom-relations

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.

@akhil-vamshi-konam akhil-vamshi-konam marked this pull request as ready for review June 15, 2026 06:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@tests/unit/test_work_item_relations.py`:
- Around line 74-198: The tests in both TestWorkItemDependencies (lines 74-198)
and TestWorkItemCustomRelations (lines 204-350) depend on implicit execution
order because earlier tests create shared state (dependencies or relations) that
later tests assume exists. To fix this, either: (1) make each test independent
by having it create the necessary dependencies/relations at the start and clean
them up at the end (as done in test_create_all_dependency_types which creates
and immediately removes), or (2) add pytest-order decorator (e.g.,
`@pytest.mark.order`(N)) to enforce the current sequence. For
TestWorkItemDependencies specifically, refactor
test_list_dependencies_after_create, test_list_reverse_dependency, and
test_remove_dependency to each set up their own blocking dependency before
testing rather than relying on prior tests. Apply the same approach to
TestWorkItemCustomRelations for its affected test methods.
🪄 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: fe6c0834-d08c-4296-b70a-ee9bf2d34375

📥 Commits

Reviewing files that changed from the base of the PR and between 491a923 and 57036aa.

📒 Files selected for processing (6)
  • plane/api/work_items/base.py
  • plane/api/work_items/custom_relations.py
  • plane/api/work_items/dependencies.py
  • plane/models/work_item_types.py
  • plane/models/work_items.py
  • tests/unit/test_work_item_relations.py

Comment thread tests/unit/test_work_item_relations.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
plane/models/work_item_relation_definitions.py (1)

54-59: 💤 Low value

Redundant model_config declaration.

PaginatedResponse (per plane/models/pagination.py:4-19) already declares model_config = ConfigDict(extra="allow", populate_by_name=True). Pydantic subclasses inherit parent config, so this redeclaration is unnecessary.

♻️ Suggested simplification
 class PaginatedWorkItemRelationDefinitionResponse(PaginatedResponse):
     """Paginated response for work item relation definitions."""

-    model_config = ConfigDict(extra="allow", populate_by_name=True)
-
     results: list[WorkItemRelationDefinition]
🤖 Prompt for 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.

In `@plane/models/work_item_relation_definitions.py` around lines 54 - 59, The
PaginatedWorkItemRelationDefinitionResponse class has a redundant model_config
declaration that duplicates the parent PaginatedResponse class configuration.
Since Pydantic subclasses inherit parent model_config automatically, remove the
model_config = ConfigDict(extra="allow", populate_by_name=True) line from
PaginatedWorkItemRelationDefinitionResponse and keep only the class docstring
and the results field definition.
🤖 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.

Nitpick comments:
In `@plane/models/work_item_relation_definitions.py`:
- Around line 54-59: The PaginatedWorkItemRelationDefinitionResponse class has a
redundant model_config declaration that duplicates the parent PaginatedResponse
class configuration. Since Pydantic subclasses inherit parent model_config
automatically, remove the model_config = ConfigDict(extra="allow",
populate_by_name=True) line from PaginatedWorkItemRelationDefinitionResponse and
keep only the class docstring and the results field definition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5dfe6b3f-9dbd-48b3-b1b0-e52d04a64ed6

📥 Commits

Reviewing files that changed from the base of the PR and between 57036aa and ecf5ba0.

📒 Files selected for processing (2)
  • plane/api/work_item_relation_definitions.py
  • plane/models/work_item_relation_definitions.py

@Prashant-Surya Prashant-Surya merged commit ce9c0b3 into main Jun 17, 2026
4 checks passed
@Prashant-Surya Prashant-Surya deleted the chore-custom-relations branch June 17, 2026 11:49
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.

2 participants