Skip to content

[Customer Entity] feat(cases): map domain enums to SN numeric IDs for cases/search filters - #868

Merged
Rashmika998 merged 2 commits into
wso2-open-operations:v2from
Rashmika998:task/sn-cases-filter-mapping
Jun 15, 2026
Merged

Rashmika998 merged 2 commits into
wso2-open-operations:v2from
Rashmika998:task/sn-cases-filter-mapping

Conversation

@Rashmika998

@Rashmika998 Rashmika998 commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The ServiceNow integration service expects stateKeys, severityKeys, and issueTypeKeys as integer arrays in the POST /cases/search payload
  • Previously these filters were silently dropped — only projectIds, deploymentIds, and caseTypes were forwarded to SN
  • Added three lookup maps (snStateIDMap, snSeverityIDMap, snIssueTypeIDMap) keyed on domain enums with IDs sourced from the SN metadata response
  • Added three converter helpers (domainStatesToSNIDs, domainPrioritiesToSNIDs, domainIssueTypesToSNIDs) that translate incoming domain enum slices to []int, skipping any unmapped values
  • SearchCases now populates stateKeys, severityKeys, and issueTypeKeys in the SN payload

Test plan

  • Call POST /cases/search with stateKeys: ["open", "work_in_progress"] — verify only matching state IDs (1, 10) appear in the SN request
  • Call with priorityKeys: ["critical", "high"] — verify SN receives severityKeys: [10, 11]
  • Call with issueTypeKeys: ["error", "total_outage"] — verify SN receives issueTypeKeys: [6, 1]
  • Call with no filter fields — verify stateKeys/severityKeys/issueTypeKeys are omitted from the SN payload (omitempty)
  • Verify existing filters (projectIds, deploymentIds, searchQuery) still work as before

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added new search filter options to filter cases by state, severity level, and issue type for more targeted case searches.

… cases/search filters

The ServiceNow integration service expects stateKeys, severityKeys, and
issueTypeKeys as integer arrays. Previously these filters were not forwarded
at all; the SN payload only carried projectIds, deploymentIds, and caseTypes.

Added lookup maps keyed on domain enums and three converter helpers so
SearchCases now translates the incoming stateKeys, priorityKeys, and
issueTypeKeys into the correct numeric IDs before calling the SN endpoint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Rashmika998, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 34 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 42810d93-164e-4aeb-8441-9f385f5e7dbc

📥 Commits

Reviewing files that changed from the base of the PR and between e011ffe and aa55a33.

📒 Files selected for processing (1)
  • entity-service/internal/service/sn_case_service.go
📝 Walkthrough

Walkthrough

sn_case_service.go gains domain-to-ServiceNow numeric ID mapping tables and three conversion helpers for CaseState, CasePriority, and CaseIssueType. The snCaseFilters struct is extended with StateKeys, SeverityKeys, and IssueTypeKeys, and SearchCases now populates those fields using the new helpers.

Changes

ServiceNow Case Search Filter Extension

Layer / File(s) Summary
Domain-to-SN mapping, helpers, and SearchCases wiring
entity-service/internal/service/sn_case_service.go
Adds integer mapping maps and conversion helpers (toSNStateKeys, toSNSeverityKeys, toSNIssueTypeKeys) inside snCaseFilters, and wires StateKeys, SeverityKeys, IssueTypeKeys into the SearchCases request payload.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • wso2-open-operations/cs-tools#855: Implements the initial ServiceNow /cases/search filter-based search in sn_case_service.go that this PR directly extends with additional filter fields.

Poem

🐇 Hippity hop, the filters grow wide,
State, severity, issue type — nothing to hide!
Domain enums mapped to integers neat,
The search payload now feels complete.
Off to ServiceNow the query shall glide! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description deviates significantly from the required template, missing critical sections like Purpose, Goals, User Stories, Release Notes, Documentation, and others. Fill in the required template sections: Purpose (with issue links), Goals, Approach, User Stories, Release Notes, Documentation, Training, Certification, Marketing, Security Checks, Samples, Related PRs, Migrations, Test Environment, and Learning. The summary and test plan provided are helpful but must be reorganized into the template structure.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: mapping domain enums to ServiceNow numeric IDs for case search filters, which directly aligns with the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@Rashmika998 Rashmika998 self-assigned this Jun 15, 2026
@Rashmika998 Rashmika998 added Type/Improvement Marks enhancements or improvements to existing features Entity Service labels Jun 15, 2026
cloby99
cloby99 previously approved these changes Jun 15, 2026

@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: 1

🤖 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/service/sn_case_service.go`:
- Around line 127-132: The snSeverityIDMap is missing an entry for
domain.CasePriorityCatastrophic, causing it to be silently skipped during
severity mapping. This results in empty severityKeys at line 297 and due to
omitempty the filter is completely omitted, broadening results. Add the missing
domain.CasePriorityCatastrophic entry to snSeverityIDMap at lines 127-132 with
the appropriate ServiceNow severity ID, or alternatively modify
domainPrioritiesToSNIDs at lines 154-162 to fail fast (return an error) when
encountering an unmapped priority value instead of skipping it silently, so
callers receive explicit feedback if an unsupported priority is requested rather
than getting unfiltered results.
🪄 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: 6124c10a-c591-4f61-9f59-a0a5a15d4ed9

📥 Commits

Reviewing files that changed from the base of the PR and between 6d9c9d3 and e011ffe.

📒 Files selected for processing (1)
  • entity-service/internal/service/sn_case_service.go

Comment thread entity-service/internal/service/sn_case_service.go
…has no SN severity equivalent

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Rashmika998
Rashmika998 merged commit 6546472 into wso2-open-operations:v2 Jun 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Entity Service Type/Improvement Marks enhancements or improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants