Confirm before replacing direct with inheritance

What does this MR do and why?

This MR enforces client confirmation within the aiCatalogItemConsumerCreate mutation before replacing an existing direct consumer with an inheritance consumer, as replacing a direct group enablement with an inheritance one is a destructive action.

References

How to set up and validate locally

In rails console enable the feature flag:

Feature.enable(:ai_catalog_group_inherited_consumers)

Create an agent in the project (Automate > Flows > New flow).

Ensure you set its visibility to public.

Enable it in the project.

Now create a group inheritance consumer for the project's root group:

mutation {
  aiCatalogItemConsumerCreate(input: {
    itemId: "gid://gitlab/Ai::Catalog::Item/<item-id>",
    target: { groupId: "gid://gitlab/Group/<top-level-group-id>" },
    consumerKind: INHERITANCE
  }) {
    errors
    itemConsumer { id consumerKind group { name } serviceAccount { username } }
  }
}

The mutation should return a response:

{
  "data": {
    "aiCatalogItemConsumerCreate": {
      "errors": [
        "Turning on this agent or flow with inheritance will replace its existing group configuration and any project configurations for this item. Set replaceExistingDirectConfigurations: true to confirm."
      ],
      "itemConsumer": null
    }
  },
  "correlationId": "01M3BH1P9CQF9WWFGJR430VEJT"
}

Now pass the argument:

mutation {
  aiCatalogItemConsumerCreate(input: {
    itemId: "gid://gitlab/Ai::Catalog::Item/<item-id>",
    target: { groupId: "gid://gitlab/Group/<top-level-group-id>" },
    consumerKind: INHERITANCE,
    replaceExistingDirectConfigurations: true
  }) {
    errors
    itemConsumer { id consumerKind group { name } serviceAccount { username } }
  }
}

You should get a success response:

{
  "data": {
    "aiCatalogItemConsumerCreate": {
      "errors": [],
      "itemConsumer": {
        "id": "gid://gitlab/Ai::Catalog::ItemConsumer/470",
        "enabled": true,
        "consumerKind": "INHERITANCE"
      }
    }
  },
  "correlationId": "01M3BH38K9NNW2D4F4Q895P0P4"
}

MR acceptance checklist

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

Related to #627517 (closed)

Edited by Luke Duncalfe

Merge request reports

Loading
Loading