Skip to content
This repository was archived by the owner on Jan 24, 2026. It is now read-only.

chore: sync with upstream goharbor/harbor#113

Open
github-actions[bot] wants to merge 4 commits into
nextfrom
sync-upstream-9mtixgq
Open

chore: sync with upstream goharbor/harbor#113
github-actions[bot] wants to merge 4 commits into
nextfrom
sync-upstream-9mtixgq

Conversation

@github-actions

@github-actions github-actions Bot commented Jan 11, 2026

Copy link
Copy Markdown

Automated PR to sync 2 new commit(s) from upstream goharbor/harbor main branch.

Merge strategy: Our changes in next are preserved on conflicts (upstream changes are additive only).

Note: The .github folder 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

    • Search endpoints for users and user groups use DAO SearchByName (fuzzy, ordered by length then name) for better relevance.
    • Removed manual sorting in handlers; results now come pre-ordered from DB.
    • Stabilized API tests: admin credentials passed to job service calls; increased wait in log rotation.
  • Refactors

    • Removed unused MostMatchSorter and onBoardCommonUserGroup.
    • Added SearchByName to controller/manager/DAO for users and user groups, with unit tests and mocks.
    • Test utilities: added getenv_bool; conditional insecure flags for cosign and helm; improved dockerd process detection.

Written for commit 746a9a3. Summary will update on new commits.

stonezdj and others added 3 commits December 31, 2025 22:14
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>
@coderabbitai

coderabbitai Bot commented Jan 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

This commit fixes the style issues introduced in 8891095 according to the output
from Gofumpt and Prettier.

Details: container-registry/harbor-next#113

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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))

@cubic-dev-ai cubic-dev-ai Bot Jan 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
Suggested change
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
Fix with Cubic

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))

@cubic-dev-ai cubic-dev-ai Bot Jan 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
Suggested change
ug, err := u.ctl.SearchByName(ctx, params.Groupname, int(*params.PageSize))
ug, err := u.ctl.List(ctx, query)
Fix with Cubic

return qs.Count()
}

func (d *dao) SearchByName(ctx context.Context, name string, limitSize int) ([]*model.UserGroup, error) {

@cubic-dev-ai cubic-dev-ai Bot Jan 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>
Fix with Cubic

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
16.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants