Fix incorrect token type in suggested reviewers registration
What does this MR do and why?
This MR fixes an invalid token type that is used in the suggested reviewers'
project registration endpoint. We need to extract the actual token value
from the response, not the PersonalAccessToken
object.
The following error can be observed in the log.
Invalid argument for string field 'access_token' (given PersonalAccessToken).
This bug is introduced in !101221 (merged).
The client-facing feature is behind a feature flag suggested_reviewers_control
and is disabled by default.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
- Set ultimate license on a group
http://gdk.test:3000/admin/groups
- Create a project in the ultimate group or use an existing one, e.g.
http://gdk.test:3000/gitlab-org/gitlab-test
- Start rails console
bundle exec rails c
- Enable SAAS simulation
ENV['GITLAB_SIMULATE_SAAS'] = '1'
- Set the feature flag
project = Project.find(2) Feature.enable(:suggested_reviewers_control, project)
- Enable the suggested reviewers setting and enable to access token creation setting
project.project_setting.update(suggested_reviewers_enabled: true) project.namespace.namespace_settings.update(resource_access_token_creation_allowed: true) project.reload
- Add a fake secret
ENV['SUGGESTED_REVIEWERS_SECRET'] = 'FAKEefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678901'
- Invoke the service and observe the response object
user = User.first service = ::Projects::RegisterSuggestedReviewersProjectService.new(project: project, current_user: user) response = service.execute # Before - fail due to type error Google::Protobuf::TypeError: Invalid argument for string field 'access_token' (given PersonalAccessToken). # After - fail due to service is not available, good enough to validate the previous error has been fixed #<ServiceResponse:0x000000013dab78c0 @http_status=nil, @message="Failed to register project", @payload={}, @reason=:client_request_failed, @status=:error>
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #377917
Edited by Tan Le