Skip to content

Fix misleading error message when assigining sec policy project

What does this MR do and why?

When you attempt to assign a security policy project to a container that has it already assigned, since !143668 (merged) we display a misleading error message:

You don't need to link the security policy projects from the group. All policies in the security policy projects are inherited already.

This MR adds a new error message for this case instead.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Database

-- https://console.postgres.ai/gitlab/gitlab-production-main/sessions/28636/commands/89247
SELECT
	1 AS one
FROM
	"security_orchestration_policy_configurations"
WHERE
	"security_orchestration_policy_configurations"."project_id" = 47965599
	AND "security_orchestration_policy_configurations"."security_policy_management_project_id" = 47965780
-- https://console.postgres.ai/gitlab/gitlab-production-main/sessions/28636/commands/89243
SELECT
	1 AS one
FROM
	"security_orchestration_policy_configurations"
WHERE
	"security_orchestration_policy_configurations"."namespace_id" = 86681698
	AND "security_orchestration_policy_configurations"."security_policy_management_project_id" = 57499346
LIMIT 1;

How to set up and validate locally

  • Create a new project and note its full path
  • Navigate to Secure > Policies and create any policy. Note the ID of the security policy project that the policy MR targets.
  • Verify that attempting to re-assign the policy projects results in the correct error message.
mutation {
  securityPolicyProjectAssign(
    input: {securityPolicyProjectId: "gid://gitlab/Project/155", fullPath: "root/blue-shape-8145"}
  ) {
    errors
  }
}
{
  "data": {
    "securityPolicyProjectAssign": {
      "errors": [
        "Security policy project is already assigned."
      ]
    }
  }
}

Related to #457065 (closed)

Edited by Dominic Bauer

Merge request reports

Loading