Loading
Adds Flow Schedule Email Notifications
What does this MR do and why?
MR 5 (of 7) that addressses: #594180. The goal of the series: users will be able to run AI flows on a cron schedule.
This MR adds failure notifications for flow schedules, following the pipeline_schedule_owner_unavailable precedent.
Emails::Ai::FlowSchedulesmailer with failure and deactivation emails (4 templates)NotificationServicemethods that email project owners and maintainers
Emails are sent on each failure and again on 3-strike deactivation. Successful runs deliberately send nothing.
How to set up and validate locally
Prerequisites
- Rails console
- GDK and
letter_openerrunning:http://172.16.123.1:3000/rails/letter_opener
- Set up in Rails (create project, users, trigger and schedule):
project = FactoryBot.create(:project)
owner = FactoryBot.create(:user).tap { |u| project.add_owner(u) }
maintainer = FactoryBot.create(:user).tap { |u| project.add_maintainer(u) }
developer = FactoryBot.create(:user).tap { |u| project.add_developer(u) } # should NOT receive an email
trigger = FactoryBot.create(:ai_flow_trigger, project: project)
schedule = FactoryBot.create(:ai_flow_schedule, flow_trigger: trigger, description: 'Nightly sync')- Note: project.creator (autogenerated by the factory) is also an
owner, so you'll see 3 recipients below, not 2.
- In rails console, call each
NotificationServicemethod directly (this MR does not wire either into a worker yet):
NotificationService.new.ai_flow_schedule_deactivated(schedule)
NotificationService.new.ai_flow_schedule_failed(schedule)- View the rendered emails in
letter_opener_web:http://172.16.123.1:3000/rails/letter_opener. - Confirm:
- Exactly three emails per call, one each to both owners and one to maintainer and none to developer.
- Grab the recipient user IDs shown in letter_opener/Sidekiq and confirm in Rails console
developer.idis absent:[owner.id, maintainer.id, developer.id]. - e.g. [209, 210, 211], the recipients you see should include 209 and 210 (plus project.creator.id), but never 211 (developer ID).
- Grab the recipient user IDs shown in letter_opener/Sidekiq and confirm in Rails console
- Subject includes the schedule's description, e.g.
Flow schedule deactivated: Nightly sync / Flow schedule failed: Nightly sync. - Body content matches the corresponding template (
ai_flow_schedule_deactivated_emailvsai_flow_schedule_failure_email).
- Exactly three emails per call, one each to both owners and one to maintainer and none to developer.
Related Stacked MRs (in order)
- Adds ai_flow_schedules table for scheduled AI f... (!250227 - merged)
- Add scheduled event type to AI flow triggers (!250805 - merged)
- Adds Flow Schedule Model (!250809 - merged)
- Add Flow Schedules API (!250821 - merged)
- Adds Flow Schedule Email Notifications (!250824 - merged) (This MR)
- Adds flow schedule execution (!250838)
- Adds FE changes for Flow Schedules (!250843)
References
Screenshots or screen recordings
| Before | After |
|---|---|
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.
Edited by Shola Quadri