[Customer Entity] Update POST /accounts/search and implement GET /accounts/{id} for ServiceNow - #1141
Conversation
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review 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 refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAccount search now accepts nested filters and forwards additional criteria. ServiceNow search and detail responses use separate domain models with nested references, nullable optional fields, updated service interfaces, and matching OpenAPI schemas. ChangesAccount search and ServiceNow account contracts
Sequence Diagram(s)sequenceDiagram
participant AccountService
participant ServiceNowSearch
participant SNAccountService
participant ServiceNowAccountAPI
AccountService->>ServiceNowSearch: send account filters
ServiceNowSearch-->>AccountService: return account views
SNAccountService->>ServiceNowAccountAPI: fetch account details by UUID
ServiceNowAccountAPI-->>SNAccountService: return nested account data
SNAccountService-->>AccountService: return SNAccountDetail
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 3
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/service/sn_account_service.go (1)
93-108: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winValidate the new account filters in both service implementations.
PodandClassificationcurrently bypass validation before reaching an external service or repository.
entity-service/internal/service/sn_account_service.go#L93-L108: validate both fields before constructing the ServiceNow payload.entity-service/internal/service/account_service.go#L41-L44: apply the same validation before invoking the repository.As per coding guidelines, service methods must validate all input before downstream calls.
🤖 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/service/sn_account_service.go` around lines 93 - 108, Validate the Pod and Classification filters before downstream calls in both entity-service/internal/service/sn_account_service.go:93-108 and entity-service/internal/service/account_service.go:41-44. Update the ServiceNow search method around snAccountSearchPayload and the repository-invoking account service method to reuse the existing filter validation behavior, returning validation errors before constructing payloads or calling dependencies.Source: Coding guidelines
🤖 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 202-206: Update SearchAccountsFilters so the optional scalar
fields SearchQuery, Pod, and Classification use *string pointers, preserving the
distinction between omitted and empty values. Adjust the associated validation,
payload construction, and repository access to safely dereference or check these
pointers while retaining existing behavior for provided values.
- Around line 242-244: Normalize empty ServiceNow timestamps to nil throughout
the entity response flow: in entity.go, make search and detail
createdOn/updatedOn fields pointers; in sn_account_service.go, pass both search
and detail timestamp values through nilIfEmpty; and in openapi.yaml, mark the
corresponding search and detail timestamp properties nullable. Update all six
listed sites consistently so absent values remain nil.
In `@entity-service/openapi.yaml`:
- Around line 2215-2233: Align the shared account contract across all affected
sites: in entity-service/openapi.yaml lines 2215-2233, scope searchQuery,
active, pod, and classification to ServiceNow or add equivalent support in
account_repo.go lines 59-65; in entity-service/openapi.yaml lines 2235-2274,
rename and define the ServiceNow view as SNAccountView while preserving the
Postgres Account contract; and in lines 2340-2346, reference the
implementation-specific search response schemas or unify them, ensuring schema
names match the corresponding Go domain types.
---
Outside diff comments:
In `@entity-service/internal/service/sn_account_service.go`:
- Around line 93-108: Validate the Pod and Classification filters before
downstream calls in both
entity-service/internal/service/sn_account_service.go:93-108 and
entity-service/internal/service/account_service.go:41-44. Update the ServiceNow
search method around snAccountSearchPayload and the repository-invoking account
service method to reuse the existing filter validation behavior, returning
validation errors before constructing payloads or calling dependencies.
🪄 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: b20d4bdd-6792-4ecd-b879-1de426ed713b
📒 Files selected for processing (6)
entity-service/internal/domain/entity.goentity-service/internal/repository/account_repo.goentity-service/internal/service/account_service.goentity-service/internal/service/interfaces.goentity-service/internal/service/sn_account_service.goentity-service/openapi.yaml
…vice (PR #1141) entity-service's POST /accounts/search and GET /accounts/{id} now return a richer, data-source-dependent shape for ServiceNow (SNAccountView/ SNAccountDetail: supportTier, owner/technicalOwner as {id, name} or {id, label}, arrToday, pod, classification, createdBy; sysId removed) and accept new filters (active, pod, classification). Both endpoints are raw passthrough in the portal backend, so no handler/client code changes are needed — only the OpenAPI spec and README were stale. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Summary
POST /accounts/searchwith additional filters (active,pod,classification) and restructures the response to include richer fields (supportTieras a label string,owner/technicalOwneras{id, name}objects,arrToday,pod,classification,createdBy)GET /accounts/{id}for the ServiceNow data source, returning full account detail withsupportTieras an{id, label}objectsysIdfrom both responses; normalises empty strings from ServiceNow tonullTest plan
POST /accounts/search— verify filters (active,pod,classification,searchQuery) are forwarded to Choreo and results match the new response shapePOST /accounts/search— verify optional fields (pod,region,supportTier,arrToday,technicalOwner,createdBy) arenull(not"") when absent in the SN responseGET /accounts/{id}— verifysupportTieris returned as{id, label}GET /accounts/{id}— verify 404 is returned for an unknown IDGET /accounts/{id}— verify 400 is returned for a malformed UUIDSummary by CodeRabbit