feat(api): add lite list endpoints for projects, members, cycles, and modules#9410
feat(api): add lite list endpoints for projects, members, cycles, and modules#9410akhil-vamshi-konam wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded lightweight paginated API endpoints for projects, cycles, modules, workspace members, and project members. Added lite serializers, routing, archived-record filtering, ordering safeguards, contract tests, and validation rejecting unsupported issue filters. ChangesLite API surface
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant API Route
participant Lite Endpoint
participant Database
participant Lite Serializer
Client->>API Route: GET lite collection
API Route->>Lite Endpoint: Dispatch request
Lite Endpoint->>Database: Query filtered records
Database-->>Lite Endpoint: Paginated records
Lite Endpoint->>Lite Serializer: Serialize results
Lite Serializer-->>Client: Paginated lite response
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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: 6
🧹 Nitpick comments (5)
apps/api/plane/tests/contract/api/test_members_lite.py (1)
86-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding error-scenario and role-assertion tests for
TestProjectMembersLite.
TestWorkspaceMembersLiteincludestest_unknown_workspace_is_rejectedand assertsitem["role"] == 20intest_lite_member_shape.TestProjectMembersLitehas neither — no test for unknown workspace/project rejection, andtest_lite_member_shapedoesn't verify the role value. Adding these would match the workspace test coverage.🤖 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 `@apps/api/plane/tests/contract/api/test_members_lite.py` around lines 86 - 102, Extend TestProjectMembersLite with an unknown workspace/project rejection test matching TestWorkspaceMembersLite, using the existing URL helper and expected error status. Update test_lite_member_shape to assert the returned member’s role equals 20, while preserving the existing field-presence checks.apps/api/plane/tests/contract/api/test_modules_lite.py (1)
52-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider asserting the lite field shape.
Same gap as
test_cycles_lite.py: the test verifies pagination and archived exclusion but does not assert the lite field set. Adding field-shape assertions (liketest_projects_lite.pydoes) would verify the "lite" contract.🤖 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 `@apps/api/plane/tests/contract/api/test_modules_lite.py` around lines 52 - 61, Update TestModulesLite.test_paginated_and_excludes_archived to assert that each returned module contains exactly the expected lite response fields, following the field-shape assertion pattern used by the related lite contract tests. Keep the existing pagination, status, and archived-module assertions unchanged.apps/api/plane/tests/contract/api/test_cycles_lite.py (2)
63-72: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider asserting the lite field shape.
The test verifies pagination and archived exclusion but does not assert which fields are present or absent in the response items.
test_projects_lite.pyincludestest_returns_only_lite_fieldsthat checks the lite field set and confirms heavy fields liketotal_membersare absent. Adding a similar assertion here would verify the "lite" contract.🤖 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 `@apps/api/plane/tests/contract/api/test_cycles_lite.py` around lines 63 - 72, Update TestCyclesLite.test_paginated_and_excludes_archived to assert each returned cycle item matches the lite response field set, including that heavy fields such as total_members are absent. Reuse the established field-shape assertion pattern from test_projects_lite.py while preserving the existing pagination and archived-cycle checks.
1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winContract tests for cycles-lite and modules-lite don't verify the lite field shape. Both tests assert pagination and archived exclusion but omit field-shape checks — the "lite" contract (which fields are present/absent) is untested.
test_projects_lite.pyincludestest_returns_only_lite_fieldsthat checks the lite field set and confirms heavy fields are absent.
apps/api/plane/tests/contract/api/test_cycles_lite.py#L63-72: Add assertions verifying lite fields present (e.g.,id,name,start_date,end_date) and computed/heavy fields absent.apps/api/plane/tests/contract/api/test_modules_lite.py#L52-61: Add similar field-shape assertions for the modules-lite response items.🤖 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 `@apps/api/plane/tests/contract/api/test_cycles_lite.py` at line 1, Update the cycles-lite and modules-lite contract tests, specifically their response-item assertions near the existing pagination and archived-exclusion checks, to verify the expected lite fields are present and computed/heavy fields are absent. Mirror the field-shape validation used by test_returns_only_lite_fields in test_projects_lite.py, covering representative fields such as id, name, start_date, and end_date where applicable.apps/api/plane/api/views/cycle.py (1)
360-399: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
CycleLiteSerializerusesfields = "__all__", undermining the "lite" purpose.The serializer docstring says "minimal data transfer" but
fields = "__all__"serializes every Cycle model field (includingexternal_id,external_source,deleted_at, etc.). This is inconsistent withProjectLiteSerializer, which uses an explicit field list and excludes computed fields liketotal_members. Define an explicit minimal field set (e.g.,id,name,start_date,end_date,description,project,workspace,owned_by) to match the "lite" contract and prevent accidental exposure of future model fields.🤖 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 `@apps/api/plane/api/views/cycle.py` around lines 360 - 399, The CycleLiteSerializer currently serializes all Cycle model fields, contradicting its lightweight contract. Update CycleLiteSerializer to use an explicit minimal fields list including id, name, start_date, end_date, description, project, workspace, and owned_by, excluding computed and internal fields and preventing future fields from being exposed.
🤖 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 `@apps/api/plane/api/views/cycle.py`:
- Line 392: Update the cycle query ordering to pass the requested value through
the existing sanitize_order_by() helper before calling order_by(), preserving
"-created_at" as the default. Apply the same validation to the matching raw
request.GET order_by usage in the module and project endpoints.
In `@apps/api/plane/api/views/issue.py`:
- Around line 317-318: Update the unsupported_filters check in the issue-listing
view to detect whether “pql” or “filters” exists in request.GET, regardless of
its value. Preserve the existing 400 response for any supplied unsupported
parameter, including empty values.
In `@apps/api/plane/api/views/member.py`:
- Line 254: Align the non-existent workspace and project handling with the
documented OpenAPI responses: update the error returns in
WorkspaceMemberLiteAPIEndpoint and ProjectMemberLiteAPIEndpoint from HTTP 400 to
HTTP 404, preserving their existing not-found response payloads and schema
declarations.
- Around line 304-321: Add an explicit project existence check in the `get`
method before querying `project_members`, validating the project belongs to the
workspace identified by `slug`. Return the documented 404 response when no
matching project exists, while preserving the existing member listing behavior
for valid projects.
In `@apps/api/plane/api/views/project.py`:
- Line 416: Sanitize the lite endpoint ordering before passing it to
QuerySet.order_by(): in apps/api/plane/api/views/project.py:416, use
sanitize_order_by with PROJECT_ORDER_BY_ALLOWLIST and "-created_at" as the
default; in apps/api/plane/api/views/module.py:314, apply the same pattern with
the module-specific order-by allowlist and appropriate default, preserving
graceful fallback for invalid input.
- Around line 401-405: Update the workspace existence check in the project view
to return HTTP 404 when the Workspace lookup by slug fails, matching the 404
response declared by the project_docs schema; leave the error payload unchanged.
---
Nitpick comments:
In `@apps/api/plane/api/views/cycle.py`:
- Around line 360-399: The CycleLiteSerializer currently serializes all Cycle
model fields, contradicting its lightweight contract. Update CycleLiteSerializer
to use an explicit minimal fields list including id, name, start_date, end_date,
description, project, workspace, and owned_by, excluding computed and internal
fields and preventing future fields from being exposed.
In `@apps/api/plane/tests/contract/api/test_cycles_lite.py`:
- Around line 63-72: Update TestCyclesLite.test_paginated_and_excludes_archived
to assert each returned cycle item matches the lite response field set,
including that heavy fields such as total_members are absent. Reuse the
established field-shape assertion pattern from test_projects_lite.py while
preserving the existing pagination and archived-cycle checks.
- Line 1: Update the cycles-lite and modules-lite contract tests, specifically
their response-item assertions near the existing pagination and
archived-exclusion checks, to verify the expected lite fields are present and
computed/heavy fields are absent. Mirror the field-shape validation used by
test_returns_only_lite_fields in test_projects_lite.py, covering representative
fields such as id, name, start_date, and end_date where applicable.
In `@apps/api/plane/tests/contract/api/test_members_lite.py`:
- Around line 86-102: Extend TestProjectMembersLite with an unknown
workspace/project rejection test matching TestWorkspaceMembersLite, using the
existing URL helper and expected error status. Update test_lite_member_shape to
assert the returned member’s role equals 20, while preserving the existing
field-presence checks.
In `@apps/api/plane/tests/contract/api/test_modules_lite.py`:
- Around line 52-61: Update TestModulesLite.test_paginated_and_excludes_archived
to assert that each returned module contains exactly the expected lite response
fields, following the field-shape assertion pattern used by the related lite
contract tests. Keep the existing pagination, status, and archived-module
assertions unchanged.
🪄 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: 9947e3d4-3777-4ea9-aec7-846b5b2293b1
📒 Files selected for processing (17)
apps/api/plane/api/serializers/__init__.pyapps/api/plane/api/serializers/member.pyapps/api/plane/api/serializers/project.pyapps/api/plane/api/urls/cycle.pyapps/api/plane/api/urls/member.pyapps/api/plane/api/urls/module.pyapps/api/plane/api/urls/project.pyapps/api/plane/api/views/__init__.pyapps/api/plane/api/views/cycle.pyapps/api/plane/api/views/issue.pyapps/api/plane/api/views/member.pyapps/api/plane/api/views/module.pyapps/api/plane/api/views/project.pyapps/api/plane/tests/contract/api/test_cycles_lite.pyapps/api/plane/tests/contract/api/test_members_lite.pyapps/api/plane/tests/contract/api/test_modules_lite.pyapps/api/plane/tests/contract/api/test_projects_lite.py
…s, update error handling for non-existent projects and workspaces
…t-lite-endpoints
Description
Adds lightweight, cursor-paginated list endpoints for projects, workspace members, project members, cycles, and modules to support picker/reference use cases with reduced payload sizes.
Changes
Added new lite endpoints:
GET /workspaces/{slug}/projects-lite/GET /workspaces/{slug}/members-lite/GET /workspaces/{slug}/projects/{project_id}/project-members-lite/GET /workspaces/{slug}/projects/{project_id}/cycles-lite/GET /workspaces/{slug}/projects/{project_id}/modules-lite/Introduced lightweight serializers for projects and members.
Added optional
include_archivedquery parameter for the projects-lite endpoint.Added OpenAPI documentation for all new endpoints.
Added contract tests covering response shape, pagination, archived filtering, and error scenarios.
Updated issue listing to return a clear
400response when unsupportedpqlorfiltersquery parameters are provided.Summary by CodeRabbit
projects-lite,cycles-lite,modules-lite,members-lite(workspace members), andproject-members-lite(GET-only).include_archived; cycles/modules/member listings exclude archived items by default.