Expose webhook event types in the flow trigger GraphQL enum

What does this MR do and why?

This is MR 5 of 5 for https://gitlab.com/gitlab-org/gitlab/-/work_items/642267.

The AiFlowTriggerEventType enum now lists the four webhook event types: MERGE_REQUEST_HOOKS, ISSUE_HOOKS, NOTE_HOOKS and WIKI_PAGE_HOOKS. The API can now return and describe triggers that use them. Before this, UserDuoStatus.flowTriggerEvents removed these types because the enum could not resolve them. That filter is gone now.

The new values are experiments from 19.7, so we can still change them. Saving a trigger with one of them still needs the ai_flow_trigger_webhook_events flag for the project. The model check from !274364 (merged) does that, and this MR adds a request spec for it through the create mutation.

AiCatalogTriggerConditionsInput still has no arguments for these types. Filter conditions for them come later, with an allowlist of filter fields. See the review on !274364 (comment 4366750440).

Related: !274364 (merged) and !276803.

There is no UI change. The UI lists event types by hand, so it does not show the new types yet.

How to set up and validate locally

  1. In GDK, open GraphiQL at /-/graphql-explorer.

  2. Check the enum values:

    {
      __type(name: "AiFlowTriggerEventType") {
        enumValues { name description }
      }
    }

    The list has MERGE_REQUEST_HOOKS, ISSUE_HOOKS, NOTE_HOOKS and WIKI_PAGE_HOOKS.

  3. With the flag off, create a trigger with merge_request_hooks (ID 11). Use a project and a service account that can run triggers:

    mutation {
      aiFlowTriggerCreate(input: {
        projectPath: "<project path>"
        userId: "gid://gitlab/User/<service account id>"
        description: "Webhook trigger"
        eventTypes: [11]
        configPath: ".gitlab/duo/agents.yml"
      }) {
        aiFlowTrigger { id eventTypes }
        errors
      }
    }

    errors says that webhook events are not available, and no trigger is created.

  4. Turn on the flag for the project in the Rails console: Feature.enable(:ai_flow_trigger_webhook_events, Project.find_by_full_path('<project path>')).

  5. Run the mutation again. The trigger is created with eventTypes: [11].

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Merge request reports

Loading
Loading