Removing all domains does not reset primary domain

Summary

There is a Primary domain dropdown menu under Deploy > Pages > Settings that will show all possible domains that can be set as a primary. However, this menu is only shown if there are domains in the Domains list. If you remove all Domains , the dropdown menu will disappear but will not reset what is considered the primary domain. When you use the API, you can still see that the primary domain is set. In my example, I had already removed http://new-test-cbjr-domain.com/ as a domain but it was still set as the primary despite not being able to change it further.

{
url: "https://test-pages-aba2e8.gitlab.io",
deployments: [
{
created_at: "2025-01-23T16:51:09.482Z",
url: "https://test-pages-aba2e8.gitlab.io",
path_prefix: null,
root_directory: null
}
],
is_unique_domain_enabled: true,
force_https: false,
pages_primary_domain: "http://new-test-cbjr-domain.com"
}

Steps to reproduce

  1. Initialize a generic Pages/Plain HTML project from template
  2. Run a pipeline to deploy pages
  3. Go to Deploy > Pages > New Domain
  4. Enter in any fake domain and ignore the SSL requirements. Save Changes.
  5. Select the new fake domain under the Primary domain dropdown. Save Changes.
  6. Delete the newly created fake domain under Domains
  7. Use the API endpoint https://gitlab.com/api/v4/projects/PROJECT_ID/pages to check the pages_primary_domain. It should be set to the one you recently deleted.
  8. Notice that you are unable to change the primary domain any longer. Use the workaround to reset it.

Example Project

What is the current bug behavior?

A user is unable to clearly reset the primary domain if the domain has been removed.

What is the expected correct behavior?

Removing all domains should reset the primary back to the generated gitlab.io address or the dropdown menu should persist.

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of: \\\`sudo gitlab-rake gitlab:env:info\\\`) (For installations from source run and paste the output of: \\\`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production\\\`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: \`sudo gitlab-rake gitlab:check SANITIZE=true\`) (For installations from source run and paste the output of: \`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true\`) (we will only investigate if the tests are passing)

Possible fixes

Workaround

  1. Add another fake domain under New Domain
  2. Save Changes and this should take you back to the main pages settings
  3. Click the dropdown for Primary domain and select the gitlab.io URL and Save Changes
  4. Go back to Domains and then remove the fake domain you created temporarily.
Edited by Cleveland Bledsoe Jr