fix: resolve project member update by username and sync update/create wrappers#909
Open
dev-aditya-hub wants to merge 1 commit into
Open
Conversation
… create - project member update --member <name> now resolves the project_members.id via ListMembers (mirroring DeleteMemberByUsername) instead of misusing user_id as the member id, which silently targeted the wrong member when ids did not coincide. - scanner UpdateScanner normalizes Auth "None" to "" the same way CreateScanner does, so updates that set --auth None no longer leave the scanner with an unrecognized auth method. - webhook UpdateWebhook trims whitespace from the endpoint URL the same way CreateWebhook does. Signed-off-by: Aditya@8767 <premjadhvar95@gmail.com>
Author
|
@qcserestipy gentle ping — would appreciate a look here when you have a slot. This one is a follow-up sweep after #908: same shape of bug (a fix lives on the create path, the matching update path was missed), three different commands. The biggest of the three is the |
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
Found three sibling-symmetry bugs while looking around the member, scanner, and webhook handlers — in each case a fix or normalization exists on the create path but was never replicated on the update path, so an update silently produces a wrong result.
Changes
project member update --member <name>was targeting the wrong rowcmd/harbor/root/project/member/update.gowas resolving--member <name>viaapi.GetUsersIdByName, which returns a user ID, and passing it asMidintoUpdateProjectMember— but Harbor's API expects the project member ID (project_members.id). These are different rows and only line up by accident.Introduced
api.UpdateMemberByUsername(mirroring the existingDeleteMemberByUsername) which callsListMembersand matches onEntityName, then routes the cmd through it. The numeric[memberName]positional and the interactive picker still use the existingUpdateMemberpath.scanner update --auth Nonewas leaving the scanner with unrecognized authpkg/api/scanner_handler.go::CreateScannernormalizes\"None\" -> \"\";UpdateScannerdid not. Both the--authflag and the interactive view surface the literal string\"None\", so an update would persist that as the auth method and the scanner adapter could no longer authenticate. Added the same normalization toUpdateScanner.webhook updatewas not trimming the endpoint URLpkg/api/webhook_handler.go::CreateWebhookcallsstrings.TrimSpaceon the endpoint URL;UpdateWebhookdid not. A trailing newline/space pasted into--endpoint-urlwould be stored verbatim. Added the trim.Test plan
harbor project member update <p> --member <user> --roleid 2updates the role of<user>(and not whichever member happens to share that user's ID)harbor project member update <p> <memberID> --roleid 2still works (positional path unchanged)harbor scanner update <name> --auth Noneno longer leaves the scanner withAuth: \"None\"in Harborharbor webhook update ... --endpoint-url \"https://example.com/hook \"stores the URL without trailing whitespace