Skip to content

[Customer Entity] Update POST /accounts/search and implement GET /accounts/{id} for ServiceNow - #1141

Merged
Rashmika998 merged 3 commits into
wso2-open-operations:mainfrom
cloby99:feat/accounts
Jul 14, 2026
Merged

Rashmika998 merged 3 commits into
wso2-open-operations:mainfrom
cloby99:feat/accounts

Conversation

@cloby99

@cloby99 cloby99 commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Extends POST /accounts/search with additional filters (active, pod, classification) and restructures the response to include richer fields (supportTier as a label string, owner/technicalOwner as {id, name} objects, arrToday, pod, classification, createdBy)
  • Implements GET /accounts/{id} for the ServiceNow data source, returning full account detail with supportTier as an {id, label} object
  • Removes sysId from both responses; normalises empty strings from ServiceNow to null

Test plan

  • POST /accounts/search — verify filters (active, pod, classification, searchQuery) are forwarded to Choreo and results match the new response shape
  • POST /accounts/search — verify optional fields (pod, region, supportTier, arrToday, technicalOwner, createdBy) are null (not "") when absent in the SN response
  • GET /accounts/{id} — verify supportTier is returned as {id, label}
  • GET /accounts/{id} — verify 404 is returned for an unknown ID
  • GET /accounts/{id} — verify 400 is returned for a malformed UUID

Summary by CodeRabbit

  • New Features
    • Added account search filters for search text, active status, pod, and classification.
    • Enhanced account search results with clearer ServiceNow account information.
    • Account details now include expanded ownership, support tier, and status information.
  • API Updates
    • Updated account detail responses to use the enhanced account detail format.
    • Improved consistency between account search results and detailed account views.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@cloby99, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6592e7c1-4c8e-4ca8-adfb-bad2728a9f9f

📥 Commits

Reviewing files that changed from the base of the PR and between 8901551 and 225aafe.

📒 Files selected for processing (1)
  • entity-service/openapi.yaml
📝 Walkthrough

Walkthrough

Account 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.

Changes

Account search and ServiceNow account contracts

Layer / File(s) Summary
Search filter propagation
entity-service/internal/domain/entity.go, entity-service/internal/repository/account_repo.go, entity-service/internal/service/account_service.go, entity-service/internal/service/sn_account_service.go
Search requests use a filters object; validation, SQL escaping, ServiceNow payload construction, and search response mapping use the updated fields.
ServiceNow account mapping
entity-service/internal/domain/entity.go, entity-service/internal/service/interfaces.go, entity-service/internal/service/sn_account_service.go
ServiceNow account references are modeled as nested objects, with separate converters for SNAccountView and SNAccountDetail.
OpenAPI account contracts
entity-service/openapi.yaml
The account detail endpoint and account schemas now describe the updated filters, ownership fields, support-tier references, and detail response.
Estimated code review effort: 4 (Complex) ~45 minutes

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
Loading

Possibly related PRs

Suggested labels: Type/Improvement, Area/Backend

Suggested reviewers: rashmika998, rksk

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only includes Summary and Test plan, missing most required template sections like Purpose, Goals, Release note, and tests. Fill in the full template sections: Purpose, Goals, Approach, User stories, Release note, Documentation, Testing, Security checks, and any applicable items like Training, Certification, and Migrations.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main ServiceNow account API changes and is specific enough for history scanning.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Validate the new account filters in both service implementations. Pod and Classification currently 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

📥 Commits

Reviewing files that changed from the base of the PR and between bb7d9b8 and 8901551.

📒 Files selected for processing (6)
  • entity-service/internal/domain/entity.go
  • entity-service/internal/repository/account_repo.go
  • entity-service/internal/service/account_service.go
  • entity-service/internal/service/interfaces.go
  • entity-service/internal/service/sn_account_service.go
  • entity-service/openapi.yaml

Comment thread entity-service/internal/domain/entity.go
Comment thread entity-service/internal/domain/entity.go
Comment thread entity-service/openapi.yaml
@Rashmika998
Rashmika998 merged commit 6861821 into wso2-open-operations:main Jul 14, 2026
1 check passed
rksk pushed a commit that referenced this pull request Jul 14, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants