Repository navigation
Changes from dev to main - #468
Conversation
[Customer Portal][BE] Add instance-based search endpoints for projects, deployments, and products
Changes from main to dev
[Customer Portal][BE] Remove cache and update deployed product search
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds instance-search functionality and related types/endpoints, removes consumption-based filtering and in-memory Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Service as Customer-Portal Service
participant Entity as Entity Module
participant Backend as External Backend
Client->>Service: POST /projects/{id}/instances/search\n(InstanceSearchPayload + idToken)
Service->>Service: extract authorization header
Service->>Entity: searchInstances(idToken, payload)
Entity->>Backend: POST /instances/search\n(payload + auth headers)
Backend-->>Entity: InstancesResponse
Entity-->>Service: InstancesResponse
Service->>Service: mapInstancesResponse()
Service-->>Client: HTTP 200 OK (mapped InstancesResponse)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 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: 2
🧹 Nitpick comments (1)
apps/customer-portal/backend/service.bal (1)
575-640: Consider a shared helper for the three instance-search endpoints.Only the scoped ID field and route-specific nouns change here. Pulling the common
entity:searchInstances+ status translation flow into one helper would make future changes to error handling or response mapping much harder to miss in one path.Also applies to: 833-898, 2566-2632
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/backend/service.bal` around lines 575 - 640, This endpoint repeats the same entity:searchInstances + status-to-response logic; extract that common flow into a shared helper (e.g., create a function searchInstancesForScope(userInfo, id, payload, scopeName) or a generic helper searchInstancesAndMap(userInfo.idToken, filters, pagination, mapFunc)) and replace the bodies of resource function post projects/[entity:IdString id]/instances/search and the other two duplicate endpoints with calls to that helper; the helper should call entity:searchInstances, inspect getStatusCode(...) for STATUS_FORBIDDEN/STATUS_UNAUTHORIZED/STATUS_BAD_REQUEST, log the same messages (use userInfo.userId and the scoped id/route-specific noun), and return the appropriate http response shape before finally mapping successful results with mapInstancesResponse.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/customer-portal/backend/openapi.yaml`:
- Line 4: Update the top-level version field in the OpenAPI spec (the "version:"
value in apps/customer-portal/backend/openapi.yaml) from 1.0.0-rc.2 to
1.0.0-rc.3 so it matches the package version in Ballerina.toml; confirm there
are no other stale version fields in the file and keep the version string
identical to the Ballerina.toml entry.
- Around line 275-307: The 200 responses for the instance-search endpoints (e.g.
operationId postProjectsIdInstancesSearch at path
/projects/{id}/instances/search and the equivalent deployment and
deployed-product instance-search paths) are missing response bodies; add an
application/json response schema for HTTP 200 for each of these three POST
endpoints that returns a top-level InstancesResponse object, and add
components.schemas definitions for Instance, InstanceMetadata, and
InstancesResponse (InstancesResponse should include an array of Instance and any
paging/metadata fields). Ensure the three paths referenced in the spec use the
newly defined InstancesResponse schema for their 200 responses so generated
clients/docs will include the returned payload.
---
Nitpick comments:
In `@apps/customer-portal/backend/service.bal`:
- Around line 575-640: This endpoint repeats the same entity:searchInstances +
status-to-response logic; extract that common flow into a shared helper (e.g.,
create a function searchInstancesForScope(userInfo, id, payload, scopeName) or a
generic helper searchInstancesAndMap(userInfo.idToken, filters, pagination,
mapFunc)) and replace the bodies of resource function post
projects/[entity:IdString id]/instances/search and the other two duplicate
endpoints with calls to that helper; the helper should call
entity:searchInstances, inspect getStatusCode(...) for
STATUS_FORBIDDEN/STATUS_UNAUTHORIZED/STATUS_BAD_REQUEST, log the same messages
(use userInfo.userId and the scoped id/route-specific noun), and return the
appropriate http response shape before finally mapping successful results with
mapInstancesResponse.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 86bbfe1c-5a50-496e-9fe9-f846fbcb7663
📒 Files selected for processing (8)
apps/customer-portal/backend/Ballerina.tomlapps/customer-portal/backend/Dependencies.tomlapps/customer-portal/backend/modules/entity/entity.balapps/customer-portal/backend/modules/entity/types.balapps/customer-portal/backend/modules/types/types.balapps/customer-portal/backend/openapi.yamlapps/customer-portal/backend/service.balapps/customer-portal/backend/utils.bal
💤 Files with no reviewable changes (1)
- apps/customer-portal/backend/Dependencies.toml
| /projects/{id}/instances/search: | ||
| post: | ||
| summary: Search instances of a project. | ||
| operationId: postProjectsIdInstancesSearch | ||
| parameters: | ||
| - name: id | ||
| in: path | ||
| description: ID of the project | ||
| required: true | ||
| schema: | ||
| $ref: '#/components/schemas/IdString' | ||
| requestBody: | ||
| description: Payload for searching instances of the project | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/InstanceSearchPayload' | ||
| required: true | ||
| responses: | ||
| "200": | ||
| description: Ok | ||
| "400": | ||
| description: BadRequest | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/ErrorPayload' | ||
| "401": | ||
| description: Unauthorized | ||
| "500": | ||
| description: InternalServerError | ||
| "403": | ||
| description: Forbidden |
There was a problem hiding this comment.
Document the 200 response body for the new instance-search endpoints.
These operations now return an instances payload, but the spec still declares 200 without content and only adds the request schema. Generated docs/clients will treat the response as empty. Add an application/json schema for 200 on all three paths and define Instance, InstanceMetadata, and InstancesResponse under components.schemas.
📘 Minimal spec fix
/projects/{id}/instances/search:
post:
responses:
"200":
description: Ok
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/InstancesResponse'Repeat the same 200 response schema for the deployment and deployed-product instance-search paths.
Also applies to: 428-460, 1423-1455, 4000-4015
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/customer-portal/backend/openapi.yaml` around lines 275 - 307, The 200
responses for the instance-search endpoints (e.g. operationId
postProjectsIdInstancesSearch at path /projects/{id}/instances/search and the
equivalent deployment and deployed-product instance-search paths) are missing
response bodies; add an application/json response schema for HTTP 200 for each
of these three POST endpoints that returns a top-level InstancesResponse object,
and add components.schemas definitions for Instance, InstanceMetadata, and
InstancesResponse (InstancesResponse should include an array of Instance and any
paging/metadata fields). Ensure the three paths referenced in the spec use the
newly defined InstancesResponse schema for their 200 responses so generated
clients/docs will include the returned payload.
[Customer Portal][BE] Update openapi.yaml file
Purpose
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning
Summary by CodeRabbit
New Features
Improvements
Chores