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::FlowSchedules mailer with failure and deactivation emails (4 templates)
  • NotificationService methods 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_opener running: http://172.16.123.1:3000/rails/letter_opener
  1. 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.
  1. In rails console, call each NotificationService method 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)
  1. View the rendered emails in letter_opener_web: http://172.16.123.1:3000/rails/letter_opener.
  2. 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.id is 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).
    • 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_email vs ai_flow_schedule_failure_email).
  1. Adds ai_flow_schedules table for scheduled AI f... (!250227 - merged)
  2. Add scheduled event type to AI flow triggers (!250805 - merged)
  3. Adds Flow Schedule Model (!250809 - merged)
  4. Add Flow Schedules API (!250821 - merged)
  5. Adds Flow Schedule Email Notifications (!250824 - merged) (This MR)
  6. Adds flow schedule execution (!250838)
  7. 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

Merge request reports

Loading
Loading