chore: sync with upstream goharbor/harbor#113
Conversation
Remove the unused function MostMatchSorter, it should not be implemented in golang, should be implement in the db query. Remove the unused function onBoardCommonUserGroup() fixes goharbor#22573 Signed-off-by: stonezdj <stonezdj@gmail.com>
refine apitest Signed-off-by: my036811 <miner.yang@broadcom.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
This commit fixes the style issues introduced in 8891095 according to the output from Gofumpt and Prettier. Details: container-registry/harbor-next#113
There was a problem hiding this comment.
3 issues found across 21 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/server/v2.0/handler/user.go">
<violation number="1" location="src/server/v2.0/handler/user.go:281">
P1: `SearchUsers` now ignores the requested page number: `SearchByName` always returns the first `pageSize` matches, so page>1 responses are incorrect even though the pagination metadata indicates otherwise. Use the original paginated query or add an offset-aware search.</violation>
</file>
<file name="src/server/v2.0/handler/usergroup.go">
<violation number="1" location="src/server/v2.0/handler/usergroup.go:205">
P2: `SearchUserGroups` now ignores `params.Page` because `SearchByName` only limits results without applying the requested offset, so all pages return the same records.</violation>
</file>
<file name="src/pkg/usergroup/dao/dao.go">
<violation number="1" location="src/pkg/usergroup/dao/dao.go:168">
P2: SearchUserGroups applies GroupType/LdapGroupDN filters to the query, but SearchByName() ignores them and returns any matching name, so the response can include groups outside the requested scope and be inconsistent with the total count.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| return operation.NewSearchUsersOK().WithXTotalCount(0).WithPayload([]*models.UserSearchRespItem{}) | ||
| } | ||
| l, err := u.ctl.List(ctx, query) | ||
| l, err := u.ctl.SearchByName(ctx, params.Username, int(*params.PageSize)) |
There was a problem hiding this comment.
P1: SearchUsers now ignores the requested page number: SearchByName always returns the first pageSize matches, so page>1 responses are incorrect even though the pagination metadata indicates otherwise. Use the original paginated query or add an offset-aware search.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/server/v2.0/handler/user.go, line 281:
<comment>`SearchUsers` now ignores the requested page number: `SearchByName` always returns the first `pageSize` matches, so page>1 responses are incorrect even though the pagination metadata indicates otherwise. Use the original paginated query or add an offset-aware search.</comment>
<file context>
@@ -279,7 +278,7 @@ func (u *usersAPI) SearchUsers(ctx context.Context, params operation.SearchUsers
return operation.NewSearchUsersOK().WithXTotalCount(0).WithPayload([]*models.UserSearchRespItem{})
}
- l, err := u.ctl.List(ctx, query)
+ l, err := u.ctl.SearchByName(ctx, params.Username, int(*params.PageSize))
if err != nil {
return u.SendError(ctx, err)
</file context>
| l, err := u.ctl.SearchByName(ctx, params.Username, int(*params.PageSize)) | |
| l, err := u.ctl.List(ctx, query) | |
| // alternatively extend SearchByName to honor query pagination before using it |
| return operation.NewSearchUserGroupsOK().WithXTotalCount(0).WithPayload([]*models.UserGroupSearchItem{}) | ||
| } | ||
| ug, err := u.ctl.List(ctx, query) | ||
| ug, err := u.ctl.SearchByName(ctx, params.Groupname, int(*params.PageSize)) |
There was a problem hiding this comment.
P2: SearchUserGroups now ignores params.Page because SearchByName only limits results without applying the requested offset, so all pages return the same records.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/server/v2.0/handler/usergroup.go, line 205:
<comment>`SearchUserGroups` now ignores `params.Page` because `SearchByName` only limits results without applying the requested offset, so all pages return the same records.</comment>
<file context>
@@ -204,14 +202,11 @@ func (u *userGroupAPI) SearchUserGroups(ctx context.Context, params operation.Se
return operation.NewSearchUserGroupsOK().WithXTotalCount(0).WithPayload([]*models.UserGroupSearchItem{})
}
- ug, err := u.ctl.List(ctx, query)
+ ug, err := u.ctl.SearchByName(ctx, params.Groupname, int(*params.PageSize))
if err != nil {
return u.SendError(ctx, err)
</file context>
| ug, err := u.ctl.SearchByName(ctx, params.Groupname, int(*params.PageSize)) | |
| ug, err := u.ctl.List(ctx, query) |
| return qs.Count() | ||
| } | ||
|
|
||
| func (d *dao) SearchByName(ctx context.Context, name string, limitSize int) ([]*model.UserGroup, error) { |
There was a problem hiding this comment.
P2: SearchUserGroups applies GroupType/LdapGroupDN filters to the query, but SearchByName() ignores them and returns any matching name, so the response can include groups outside the requested scope and be inconsistent with the total count.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/pkg/usergroup/dao/dao.go, line 168:
<comment>SearchUserGroups applies GroupType/LdapGroupDN filters to the query, but SearchByName() ignores them and returns any matching name, so the response can include groups outside the requested scope and be inconsistent with the total count.</comment>
<file context>
@@ -185,3 +164,19 @@ func (d *dao) Count(ctx context.Context, query *q.Query) (int64, error) {
return qs.Count()
}
+
+func (d *dao) SearchByName(ctx context.Context, name string, limitSize int) ([]*model.UserGroup, error) {
+ o, err := orm.FromContext(ctx)
+ if err != nil {
</file context>
|


Automated PR to sync 2 new commit(s) from upstream goharbor/harbor main branch.
Merge strategy: Our changes in
nextare preserved on conflicts (upstream changes are additive only).Note: The
.githubfolder is preserved and not synced from upstream.Summary by cubic
Sync with upstream Harbor to fix user and group search. Adds DAO-level fuzzy search with DB ordering and refines tests to work in proxy environments.
Bug Fixes
Refactors
Written for commit 746a9a3. Summary will update on new commits.