Skip to content

Code Suggestions PAT field is no longer required on SM

What does this MR do and why?

Previously, "Personal access token" input field in the "Code Suggestions" section of the Application Settings could not be empty if "Enable Code Suggestions for this instance" toggle was ON. This was only allowed when the toggle was OFF.

Now you could have "Personal access token" input field empty even when the toggle is ON.

This change is necessary to support both the new and the old token flow. In the flow, the Code Suggestions token will be synced from the CustomersDot, so it will not be required to be set by the user.

Screenshots or screen recordings

Master

Checking the checkbox and sending an empty field will result in validation error:

Screenshot_2023-07-31_at_13.43.42

This branch

You could have an empty token field and the instance toggle checked:

Screenshot_2023-07-31_at_13.25.30

It wouldn't result in any errors sending the form:

Screenshot_2023-07-31_at_13.27.20

How to set up and validate locally

Prerequisite: Make sure you have a license on your GDK! (so it will act as EE Premium/Ultimate)
Otherwise, the "Code Suggestions" section will not be shown to you in Application Settings.

Master

  1. Check master
  2. Visit http://localhost:3000/admin/application_settings/general, scroll down, and find the Code Suggestions section
  3. Check the checkbox and leave the PAT field empty
  4. Save the settings
  5. The validation error should appear

On this branch

  1. Check this branch: 419770-ai-make-pat-field-optional-for-sm
  2. Visit http://localhost:3000/admin/application_settings/general, scroll down, and find the Code Suggestions section
  3. Check the checkbox and leave the PAT field empty
  4. Save the settings
  5. Make sure no errors happened
  6. In rails console, you could double-check the state in the DB:
[7] pry(main)> ::Gitlab::CurrentSettings.reload.ai_access_token 
=> ""
[8] pry(main)> ::Gitlab::CurrentSettings.reload.instance_level_code_suggestions_enabled
=> true

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #419770 (closed)

Edited by Aleksei Lipniagov

Merge request reports

Loading