[Entity-Service] Support sortBy on POST /users/search for the Postgres data source - #1875
Merged
Rashmika998 merged 1 commit intoSep 21, 2026
Conversation
…s data source The Postgres path rejected any sortBy with "sortBy is only supported for the ServiceNow data source", although the OpenAPI contract advertises name/createdOn/updatedOn for this endpoint and the CSM users page always sends name/asc, so that page's user search returned a 400. Validate the field and order the same way the ServiceNow adapter does, and map them to fixed SQL expressions in the repository. name sorts case-insensitively on the display name, falling back to first + last name and then user name for the few rows with no display name; u.id is always the final tie-break so pages are stable. No sortBy keeps the newest-first default. Verified against staging through the real service and repository: five sorts (name asc/desc, createdOn desc, updatedOn asc, name with order omitted), each compared to hand-written SQL across four pages including the tail. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedNext included review available in 30 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: wso2-open-operations/cs-tools/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
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 |
shayanmalinda
approved these changes
Sep 21, 2026
Rashmika998
merged commit Sep 21, 2026
3efe101
into
wso2-open-operations:dev-app-csm-portal
2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /users/searchon the Postgres data source rejected anysortBy:The OpenAPI contract already advertises
sortBy(name/createdOn/updatedOn) for this endpoint, and the CSM users page always sends{"field": "name", "order": "asc"}, so that page's search returned a 400.namesorts case-insensitively on the display name, falling back to first + last name and then the user name, because"user".nameis empty for a few synced rows (5 of 2,937 in staging).u.idis always the last tie-break so pages are stable across offsets.sortBykeeps the previous newest-first default.Verification
userOrderBy, including that an unknown field falls back to the default and never reaches SQL.gofmt,go vet,gosec(0 issues),govulncheckclean.go testhas one failure,TestSNCaseService_CreateCase_PublishesCaseCreated, which fails the same way without this change.🤖 Generated with Claude Code