[Customer Entity] Improve case API response consistency for ServiceNow data source - #934
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ct in case search
|
Warning Review limit reached
More reviews will be available in 8 minutes and 23 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughRenames the case type value from ChangesCase type rename and nullable field expansion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
entity-service/internal/repository/case_repo.go (1)
120-127: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPopulate the new detail
typeandengagementTypefields for Postgres cases.
CaseViewnow exposes these fields andSearchCasesalready returns them, butGetCaseByIDstill doesn’t selectc.type/c.engagement_type, so Postgres detail responses serialize them asnull. Add the columns to this SELECT/Scan path and assigncv.Type/cv.EngagementType.Also applies to: 151-165
🤖 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 `@entity-service/internal/repository/case_repo.go` around lines 120 - 127, Populate the new CaseView detail fields in the Postgres GetCaseByID query path. Update the SELECT built in case_repo.go and the matching Scan/assignment logic in GetCaseByID to include c.type and c.engagement_type, then assign the values to cv.Type and cv.EngagementType so detail responses no longer serialize them as null. Use the existing GetCaseByID, CaseView, and SearchCases patterns as a guide to keep the row mapping aligned.
🤖 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 `@entity-service/internal/domain/entity.go`:
- Around line 568-571: CaseView still models DeploymentDetails as a non-pointer
value, so missing deployments can serialize as an empty EntityRef instead of
null. Change CaseView.DeploymentDetails to *EntityRef, then update every
CaseView builder/mapper that populates deployment data to set nil when no
deployment exists and only allocate an EntityRef when present. Also align the
generated API/OpenAPI schema and any related response model conversions that
reference CaseView, DeploymentDetails, and EntityRef so deployment is documented
and emitted as nullable.
In `@entity-service/internal/service/sn_case_service.go`:
- Around line 448-461: The optional ServiceNow reference mapping in the SN case
conversion logic should not assign empty-string IDs when the ref object exists
but its source ID is blank. Update the conversion branches in the method that
populates the domain entity refs for ProductDetails, Catalog, CatalogItem,
AssignedTeam, and Conversation to follow the same sysidToUUID(...) != "" guard
used for DeployedProductDetails, so only valid converted UUIDs are serialized
and empty responses stay omitted.
- Around line 339-340: The validation message in the case creation path is
stale: in the req.Type check inside the case creation logic, replace the
misleading typeKey wording with the actual request field name type so API
clients see an accurate error. Update the apierror.ValidationError message in
the case creation method to reference req.Type directly and keep the enum field
naming consistent with other request validations.
- Around line 136-155: Add the missing reverse mapping for the engagement case
type in snCaseTypeSysidMap so snCaseTypeToDomain can return "engagement" instead
of defaulting to "case". Update the mapping table alongside the existing
case_type sysid entries, and ensure the conversion logic in snCaseTypeToDomain
still falls back to "case" only for nil or unrecognized sysids.
---
Outside diff comments:
In `@entity-service/internal/repository/case_repo.go`:
- Around line 120-127: Populate the new CaseView detail fields in the Postgres
GetCaseByID query path. Update the SELECT built in case_repo.go and the matching
Scan/assignment logic in GetCaseByID to include c.type and c.engagement_type,
then assign the values to cv.Type and cv.EngagementType so detail responses no
longer serialize them as null. Use the existing GetCaseByID, CaseView, and
SearchCases patterns as a guide to keep the row mapping aligned.
🪄 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: 1bd9dd87-3000-4938-8c82-fa2568c60986
📒 Files selected for processing (7)
entity-service/CLAUDE.mdentity-service/internal/domain/entity.goentity-service/internal/repository/case_repo.goentity-service/internal/service/case_service.goentity-service/internal/service/sn_case_service.goentity-service/migrations/000008_create_cases.up.sqlentity-service/openapi.yaml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…on error Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…onversion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… case type rename and nullable fields - Rename type enum value support→case in CaseCreatePayload and CaseSearchFilters - Add type and engagementType nullable fields to CaseView - Add catalog, catalogItem, assignedTeam, conversation nullable EntityRef fields to CaseView - Mark deployment, deployedProduct, product as nullable in CaseView - Add type field and mark deployment, deployedProduct as nullable in CaseSearchView - Update test payload and docs to use type: "case" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…support->case; nullable CaseView refs) - Rename case type value 'support' -> 'case' across BeCaseType, BeCaseCreatePayload (POST /cases), the case-type filter (caseType.ts: label 'Support' -> 'Case'), and CsmCaseCreatePage. Matches the entity PR wso2-open-operations#934 rename. - BeCaseView: add nullable type/engagementType and catalog/catalogItem/ assignedTeam/conversation EntityRefs; mark deployment/deployedProduct nullable. - BeCaseSearchView: add 'type'; mark deployment/deployedProduct nullable. Map it onto the row (caseType: c.type). Pure contract alignment. NOTE: depends on BE PR wso2-open-operations#938 — merge this after it, or the cases list/create will send the new 'case' value to a BE that still expects 'support'.
…and nullable fields - Rename type enum value support→case in CaseCreatePayload and CaseSearchFilters - Add type and engagementType nullable fields to CaseView - Add catalog, catalogItem, assignedTeam, conversation nullable EntityRef fields to CaseView - Mark deployment, deployedProduct, product as nullable in CaseView - Add type field and mark deployment, deployedProduct, product as nullable in CaseSearchView - Update test payload and docs to use type: "case" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gnment [CSM Portal][BE] align with entity service PR #934: case type rename and nullable fields
…support->case; nullable CaseView refs) - Rename case type value 'support' -> 'case' across BeCaseType, BeCaseCreatePayload (POST /cases), the case-type filter (caseType.ts: label 'Support' -> 'Case'), and CsmCaseCreatePage. Matches the entity PR wso2-open-operations#934 rename. - BeCaseView: add nullable type/engagementType and catalog/catalogItem/ assignedTeam/conversation EntityRefs; mark deployment/deployedProduct nullable. - BeCaseSearchView: add 'type'; mark deployment/deployedProduct nullable. Map it onto the row (caseType: c.type). Pure contract alignment. NOTE: depends on BE PR wso2-open-operations#938 — merge this after it, or the cases list/create will send the new 'case' value to a BE that still expects 'support'.
Summary
cases/searchfields toGET /cases/{id}response (CaseViewnow extendsSearchCaseViewfields:catalog,catalogItem,assignedTeam,conversation,caseType,engagementType)caseType→typein both search and detail responses; map SNcaseTypesysids to domain enum values (case,service_request, etc.)supportcase type enum tocaseacross migration, validation, and OpenAPI specnullinstead of empty strings/objects for absent fields:deployedProduct,deployment,product,UserRefsub-fields,CaseView.DeployedProductDetailsSummary by CodeRabbit
New Features
casetype by default, including search and create flows.Bug Fixes