[Customer Portal][BE] Enhance case search validation and add active chats count to conversation stats - #257
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a CaseType enum, updates case-related types (new/optional fields and Variable type), introduces case-type-specific payload validation, replaces string case type filters with enum arrays, adds product category and activeCount, and adjusts Dependencies.toml (downgrades and removes uuid). Changes
Sequence DiagramsequenceDiagram
participant Client as Client
participant Service as Service
participant Validator as Validator
participant CaseCreator as CaseCreation
participant DB as Database
Client->>Service: createCase(CaseCreatePayload)
Service->>Validator: validateCaseCreatePayload(payload)
alt validation fails
Validator-->>Service: "error message"
Service-->>Client: 400 Bad Request
else validation OK
Validator-->>Service: nil
Service->>CaseCreator: processCase(payload)
CaseCreator->>DB: insert case (type-specific fields)
DB-->>CaseCreator: created case
CaseCreator-->>Service: case response
Service-->>Client: 201 Created
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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: 1
🧹 Nitpick comments (1)
apps/customer-portal/backend/modules/entity/utils.bal (1)
200-203: Add a defensive fallback for unsupported future case types.Right now unsupported handling is hardcoded to two enum members. A final
elsebranch is safer if new enum values are added later.♻️ Suggested refactor
- } else if caseType == ANNOUNCEMENT || caseType == SECURITY_REPORT_ANALYSIS { + } else { return string `Case type ${caseType} is not supported.`; } + return ();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/backend/modules/entity/utils.bal` around lines 200 - 203, The current branch only handles ANNOUNCEMENT and SECURITY_REPORT_ANALYSIS specifically, which will miss any future enum values; update the conditional in the function using the caseType variable (the block that currently checks "else if caseType == ANNOUNCEMENT || caseType == SECURITY_REPORT_ANALYSIS") to add a final else fallback that returns a generic "Case type ${caseType} is not supported." message for any other enum members so unsupported/new case types are defensively handled.
🤖 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/modules/entity/utils.bal`:
- Around line 180-182: The validation error string returned when description is
empty contains typos; update the return value in the block that checks "if
description is () || description.trim().length() == 0" to a correct, user-facing
message (e.g., "Description cannot be empty for default case.") by replacing the
existing incorrect text ("Description cannnot be epty for default case.") in the
function in utils.bal that performs description validation.
---
Nitpick comments:
In `@apps/customer-portal/backend/modules/entity/utils.bal`:
- Around line 200-203: The current branch only handles ANNOUNCEMENT and
SECURITY_REPORT_ANALYSIS specifically, which will miss any future enum values;
update the conditional in the function using the caseType variable (the block
that currently checks "else if caseType == ANNOUNCEMENT || caseType ==
SECURITY_REPORT_ANALYSIS") to add a final else fallback that returns a generic
"Case type ${caseType} is not supported." message for any other enum members so
unsupported/new case types are defensively handled.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/customer-portal/backend/Dependencies.tomlapps/customer-portal/backend/modules/entity/enums.balapps/customer-portal/backend/modules/entity/types.balapps/customer-portal/backend/modules/entity/utils.balapps/customer-portal/backend/modules/types/types.balapps/customer-portal/backend/service.balapps/customer-portal/backend/utils.bal
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
apps/customer-portal/backend/modules/entity/utils.bal (1)
180-182:⚠️ Potential issue | 🟡 MinorFix typo in user-facing validation message.
Line 181 still contains typos (
cannnot,epty) in an API-facing error string.✏️ Suggested fix
- return "Description cannnot be epty for default case."; + return "Description cannot be empty for default case.";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/backend/modules/entity/utils.bal` around lines 180 - 182, The user-facing validation message contains typos; update the returned string in the block checking description (the conditional that uses description.trim().length() and returns the error) to a correct, clear message such as "Description cannot be empty for default case."—replace the misspelled "cannnot" (and any other variants like "epty") with the correct spelling while leaving the conditional logic (the description is () || description.trim().length() == 0 check) unchanged.
🤖 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/modules/entity/utils.bal`:
- Around line 183-195: The current nil-only checks allow empty or
whitespace-only strings; update the validation in the same block that checks
caseType (including SERVICE_REQUEST branch) to reject values that are nil or
blank by testing both nil and trimmed length 0 for payload.issueTypeKey,
payload.severityKey, payload.catalogId and payload.catalogItemId (e.g., replace
the nil-only checks with a compound check that treats "" and " " as invalid by
verifying the field is not nil and payload.<field>.trim().length() > 0 or
equivalent in Ballerina using a type test for string and trim/length).
---
Duplicate comments:
In `@apps/customer-portal/backend/modules/entity/utils.bal`:
- Around line 180-182: The user-facing validation message contains typos; update
the returned string in the block checking description (the conditional that uses
description.trim().length() and returns the error) to a correct, clear message
such as "Description cannot be empty for default case."—replace the misspelled
"cannnot" (and any other variants like "epty") with the correct spelling while
leaving the conditional logic (the description is () ||
description.trim().length() == 0 check) unchanged.
1f1b7cc
into
wso2-open-operations:customer-portal-milestone-1
Description
This PR includes the following enhancements:
Changes
1️⃣ Case Search & Payload Validation Enhancement
Reason:
Supporting service requests are now part of the case creation workflow. Proper validation ensures:
2️⃣ Add Active Chats Count to Conversation Stats
Reason:
The dashboard requires visibility into the number of active chats.
Testing
Impact
Related PRs
Summary by CodeRabbit
New Features
Chores