Skip to content

Frontend: Show API error in Secrets Manager settings

When changing the project visibility settings in https://gitlab.com/gitlab-org/cloud-native/charts/openbao/edit, I noticed this error:

image

The GraphQL query in question:

{
  "operationName": "getSecretManagerStatus",
  "variables": {
    "projectPath": "gitlab-org/cloud-native/charts/openbao"
  },
  "query": "query getSecretManagerStatus($projectPath: ID!) {\n  projectSecretsManager(projectPath: $projectPath) {\n    status\n    __typename\n  }\n}"
}

The response:

{
  "errors": [
    {
      "message": "The resource that you are attempting to access does not exist or you don't have permission to perform this action",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "projectSecretsManager"
      ]
    }
  ],
  "data": {
    "projectSecretsManager": null
  }
}

On some environments, this is due to Openbao integration work not being complete yet. However, we should still show the API error instead of a generic error message on the UI.

Proposal

We can update ee/app/assets/javascripts/pages/projects/shared/permissions/secrets_manager/secrets_manager_settings.vue to show the error message returned from the secretManagerStatus apollo query.

We should also make sure that the toggle is disabled if we encounter an error while fetching the Secrets Manager status.

Verification

This can be verified without setting up openbao.

Simulating an error message

If #549940 (closed) has not been addressed yet, an error will also be raised if the secrets_manager feature flag is disabled.

Otherwise, we can mock the error by raising one in the resolve method in ee/app/graphql/mutations/secrets_management/project_secrets_managers/initialize.rb

Verification

  1. Go to your project. From the sidebar, go to Settings > General.
  2. Expand Visibility, project features, permissions and go to the Secrets manager section.
  3. Verify that we are showing the error message from the API and that the toggle is disabled.
Edited by 🤖 GitLab Bot 🤖