Loading
Add webhook event types to flow triggers behind a flag
What does this MR do and why?
This is MR 1 of 5 for the issue. Flow triggers will start from the merge request, issue, note and wiki page webhook events.
This MR adds four event types to Ai::FlowTrigger: merge_request_hooks, issue_hooks, note_hooks and wiki_page_hooks. It also adds the ai_flow_trigger_webhook_events wip flag. Nothing dispatches these events yet.
WEBHOOK_EVENT_TYPESlists the four scopes.pipeline_hooksis not in it, because it has its own dispatch inEE::Ci::Pipelines::HookService.- A trigger can only add a webhook event type when the flag is on for its project. Stored triggers stay valid when the flag goes off, so they can still be turned off or edited.
- The flag actor is the project. A group trigger can use the webhook types only when the flag is on for everyone. The dispatch MR decides how group triggers work with webhook events.
- The new types have no
ALLOWED_FILTER_FIELDSentry, so a filter can use any payload field. - GraphQL doesn't show the new types.
AiFlowTriggerEventTypeandAiCatalogTriggerConditionsInputskip them, and the GraphQL docs and introspection files don't change. The names are still an open question in the issue, and GraphQL enum values are a public contract. UserDuoStatus.flowTriggerEventsreturns event types through the GraphQL enum. It now drops the webhook types, so the field doesn't fail to resolve when a trigger has one.- The webhook types bill the service account, like
pipeline_hooks,merge_requestandwork_item. Billing changed recently in 83dd5732 (https://gitlab.com/gitlab-org/gitlab/-/work_items/600549), so please check that this fits.
The IDs are 11 to 14. The proof of concept used 10 to 13, but security_policy took 10 since then.
Next MRs:
- Find the resource from the webhook payload in
EventTriggerService. - The worker.
- Dispatch from
EE::Project#execute_hooks. - GraphQL: expose the new event types.
References
- https://gitlab.com/gitlab-org/gitlab/-/work_items/642267
- Rollout issue: #642623
Screenshots or screen recordings
This MR changes nothing in the UI.
How to set up and validate locally
There is no UI change. You can check the validation in the Rails console:
project = Project.first
sa = User.service_account.first
trigger = Ai::FlowTrigger.new(project: project, user: sa, description: 'Webhook test', config_path: 'flow.yml',
event_types: [Ai::FlowTrigger::EVENT_TYPES[:merge_request_hooks]])
Feature.disable(:ai_flow_trigger_webhook_events)
trigger.valid? # => false
trigger.errors[:event_types] # => ["webhook events are not available"]
Feature.enable(:ai_flow_trigger_webhook_events, project)
trigger.valid? # => trueMR 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.
Edited by Vitali Tatarintev