Fix UserSearchSort JSON tags casing#633
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in the UserSearchSort struct by adding missing JSON tags to the Field and Desc fields. Previously, these fields were marshaled with Go's default casing (capitalized), causing API requests to fail with error E011003 indicating that the sort[0].field field is required. The fix ensures proper JSON serialization with lowercase field names, aligning with the API's expectations and the codebase's existing JSON tagging conventions.
Key Changes
- Added
json:"field"tag to theFieldstring field inUserSearchSortstruct - Added
json:"desc"tag to theDescbool field inUserSearchSortstruct
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
aviadl
left a comment
There was a problem hiding this comment.
Thank you for your contribution
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
descope/types.go:915
- The
UserSearchOptionsstruct is missing JSON tags for all fields. Since this struct is serialized in API requests (as seen inmakeSearchAllRequest), fields should have JSON tags to ensure proper marshaling. For example,Pageshould bePage int32 \json:"page"`andTenantIDsshould beTenantIDs []string `json:"tenantIds"``.
type UserSearchOptions struct {
Page int32
Limit int32
Sort []UserSearchSort
Text string
Emails []string
Phones []string
Statuses []UserStatus
Roles []string
TenantIDs []string
SSOAppIDs []string
CustomAttributes map[string]any
WithTestUsers bool
TestUsersOnly bool
LoginIDs []string
UserIDs []string
FromCreatedTime int64
ToCreatedTime int64
FromModifiedTime int64
ToModifiedTime int64
TenantRoleIDs map[string]*RoleList
TenantRoleNames map[string]*RoleList
IncludeSubTenants bool
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
Can this be merged? @aviadl |
Description
This PR adds missing JSON tags to the
UserSearchSortstruct fields indescope/types.go.Previously, the
FieldandDescfields were missing JSON tags, which caused them to be marshaled with default Go casing (capitalized).This caused errors when using the API(
{"errorCode":"E011003","errorDescription":"Request is invalid","errorMessage":"The sort[0].field field is required","message":"The sort[0].field field is required"}Must