[Customer Portal][BE] Update product search payload by adding the filters - #483
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 15 seconds. ⌛ 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
apps/customer-portal/backend/openapi.yaml (2)
2826-2845:⚠️ Potential issue | 🟠 MajorRestore
durationInMinutestoCallRequestUpdatePayload.The backend type and validation still consume this field, so removing it from the published schema makes the API contract drift from the server implementation. Re-add it here with the numeric constraints.
Proposed fix
utcTimes: type: array description: New preferred UTC times for the call (mandatory when stateKey is 2) items: $ref: '#/components/schemas/DateTime' + durationInMinutes: + minimum: 1 + type: integer + description: Duration in minutes (mandatory when stateKey is 2) + format: int64 additionalProperties: false description: Request payload for updating a call request.Based on learnings,
CallRequestUpdatePayload.durationInMinutesis strictly required whenstateKeyis2, and the OpenAPI schema should includeminimum: 1andformat: int64.🤖 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 2826 - 2845, Restore the durationInMinutes field to the CallRequestUpdatePayload schema: add a properties.durationInMinutes entry with type: integer, format: int64 and minimum: 1, and add a conditional rule so that when stateKey is 2 the schema requires durationInMinutes (use an if/then block with if: properties: { stateKey: { const: 2 } } then: { required: [ "durationInMinutes" ] }). Keep additionalProperties: false and leave other fields unchanged.
4329-4341:⚠️ Potential issue | 🟡 MinorConstrain
Product.classto the supported values.Declaring this as a plain
stringdrops the enum contract the backend already has, so generated clients and docs will not advertise the only valid values. Model it as an enum here, or reference a sharedProductClassschema.Proposed fix
class: type: string description: "Product class (service_model, software_model, or product_model)" + enum: + - service_model + - software_model + - product_model🤖 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 4329 - 4341, The Product.schema currently defines the property "class" as type: string which loses the backend enum constraint; update the "class" property (Product.class) to either reference a shared enum schema (e.g., $ref: '#/components/schemas/ProductClass') or replace type: string with an explicit enum list (e.g., enum: [service_model, software_model, product_model]) so generated clients/docs advertise the valid values; ensure the chosen enum schema is added under components/schemas if it doesn't already exist and update any usages to reference it.
🧹 Nitpick comments (1)
apps/customer-portal/backend/modules/entity/types.bal (1)
1589-1590: PreferProductClassover rawstringforProduct.'class.At Line 1590, using
stringweakens the response contract even thoughProductClassalready exists for this domain. Typing this field asProductClasskeeps request/response semantics consistent and prevents invalid class values.♻️ Proposed refactor
public type Product record {| # ID IdString id; # Name string name; # Product class (service_model, software_model, or product_model) - string 'class; + ProductClass 'class; json...; |};🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/backend/modules/entity/types.bal` around lines 1589 - 1590, The Product record currently types the field Product.'class as raw string which weakens the contract; change its type to the existing ProductClass type so the field reads Product.'class: ProductClass (update any necessary imports/qualified names where ProductClass is defined and run CI/types checks to ensure all usages of Product.'class conform to the enum/union values); update any serialization/deserialization or tests that assume a plain string to use ProductClass values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/customer-portal/backend/openapi.yaml`:
- Around line 2826-2845: Restore the durationInMinutes field to the
CallRequestUpdatePayload schema: add a properties.durationInMinutes entry with
type: integer, format: int64 and minimum: 1, and add a conditional rule so that
when stateKey is 2 the schema requires durationInMinutes (use an if/then block
with if: properties: { stateKey: { const: 2 } } then: { required: [
"durationInMinutes" ] }). Keep additionalProperties: false and leave other
fields unchanged.
- Around line 4329-4341: The Product.schema currently defines the property
"class" as type: string which loses the backend enum constraint; update the
"class" property (Product.class) to either reference a shared enum schema (e.g.,
$ref: '#/components/schemas/ProductClass') or replace type: string with an
explicit enum list (e.g., enum: [service_model, software_model, product_model])
so generated clients/docs advertise the valid values; ensure the chosen enum
schema is added under components/schemas if it doesn't already exist and update
any usages to reference it.
---
Nitpick comments:
In `@apps/customer-portal/backend/modules/entity/types.bal`:
- Around line 1589-1590: The Product record currently types the field
Product.'class as raw string which weakens the contract; change its type to the
existing ProductClass type so the field reads Product.'class: ProductClass
(update any necessary imports/qualified names where ProductClass is defined and
run CI/types checks to ensure all usages of Product.'class conform to the
enum/union values); update any serialization/deserialization or tests that
assume a plain string to use ProductClass values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b45576d4-97cf-46c0-97e7-88f5a4d6ba1b
📒 Files selected for processing (5)
apps/customer-portal/backend/modules/entity/enums.balapps/customer-portal/backend/modules/entity/types.balapps/customer-portal/backend/modules/types/types.balapps/customer-portal/backend/openapi.yamlapps/customer-portal/backend/utils.bal
Co-authored-by: Anuradha Basnayake <anuradhabsnk@gmail.com>
Co-authored-by: Anuradha Basnayake <anuradhabsnk@gmail.com>
Co-authored-by: Anuradha Basnayake <anuradhabsnk@gmail.com>
9619962
into
wso2-open-operations:dev-app-customer-portal
Description
Summary by CodeRabbit
New Features
Documentation