Skip to content

#2041: Migrate IVC CHAMPVA email to VANotify::V2::QueueEmailJob#27783

Open
sarahwcodes wants to merge 8 commits intomasterfrom
sw-2041-migrate-ivc-champva
Open

#2041: Migrate IVC CHAMPVA email to VANotify::V2::QueueEmailJob#27783
sarahwcodes wants to merge 8 commits intomasterfrom
sw-2041-migrate-ivc-champva

Conversation

@sarahwcodes
Copy link
Copy Markdown
Contributor

@sarahwcodes sarahwcodes commented Apr 15, 2026

Keep your PR as a Draft until it's ready for Platform review. A PR is ready for Platform review when it has a teammate approval and tests, linting, and settings checks pass CI. See these tips on how to avoid common delays in getting your PR merged.

Summary

  • This work is behind a feature toggle (flipper): YES/NO
  • (Summarize the changes that have been made to the platform) Migrates IVC ChampVA email to use the new VANotify::V2::QueueEmailJob
  • (If bug, how to reproduce)
  • (What is the solution, why is this the solution?) VANotify::V2::QueueEmailJob provides safer handling of personalization data when sending emails through Sidekiq
  • (Which team do you work for, does your team own the maintenance of this component?) VANotify, no
  • (If introducing a flipper, what is the success criteria being targeted?)

Related issue(s)

  • Link to ticket created in va.gov-team repo OR screenshot of Jira ticket if your team uses Jira Strike #2041
  • Link to previous change of the code/bug (if applicable)
  • Link to epic if not included in ticket

Testing done

  • New code is covered by unit tests
  • Describe what the old behavior was prior to the change
  • Describe the steps required to verify your changes are working as expected. Exclusively stating 'Specs run' is NOT acceptable as appropriate testing
    Confirm email sends correctly prior to turning flipper on:
puts "Flipper enabled? #{Flipper.enabled?(:va_notify_v2_ivc_champva_email)}"
 # Expected: false
 email = 'sarah.wheeler4@va.gov'
 form_data = {
   email: email,
   form_number: '10-10D',
   first_name: 'Sarah',
   last_name: 'Wheeler',
   file_count: 2,
   pega_status: 'Processed',
   date_submitted: Time.zone.now.strftime('%B %d, %Y'),
   form_uuid: SecureRandom.uuid
 }

 # Verify template ID resolves
 template_id = Settings.vanotify.services.ivc_champva.template_id.form_10_10d_email
 puts "Template ID: #{template_id}"
 puts "API Key present? #{Settings.vanotify.services.ivc_champva.api_key.present?}"

 # Send the email via V1 path
 result = IvcChampva::Email.new(form_data).send_email
 puts "send_email returned: #{result}"
  • If this work is behind a flipper:
    • Tests need to be written for both the flipper on and flipper off scenarios. Docs.
    • What is the testing plan for rolling out the feature?

Screenshots

Note: Optional

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?

nathanbwright
nathanbwright previously approved these changes Apr 20, 2026
@nathanbwright nathanbwright marked this pull request as ready for review April 20, 2026 15:46
@nathanbwright nathanbwright requested review from a team as code owners April 20, 2026 15:46
@rmtolmach rmtolmach requested a review from Copilot April 20, 2026 20:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates IVC CHAMPVA email sending to optionally use VANotify::V2::QueueEmailJob (via Flipper) to improve handling of personalization data in Sidekiq.

Changes:

  • Add va_notify_v2_ivc_champva_email feature flag to control V1 (VANotify::EmailJob) vs V2 (VANotify::V2::QueueEmailJob) behavior.
  • Refactor IvcChampva::Email#send_email to route sending through a helper that selects V1/V2 based on the flag.
  • Expand service specs to cover both Flipper states (and error handling) for enqueueing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
modules/ivc_champva/app/services/ivc_champva/email.rb Adds Flipper-gated routing to V2 queueing and extracts enqueue logic into a helper method.
modules/ivc_champva/spec/services/email_spec.rb Updates specs to validate behavior for Flipper off/on and job enqueue parameters.
config/features.yml Introduces the va_notify_v2_ivc_champva_email feature definition.

Comment on lines +22 to +25
let(:expected_template_id) { Settings.vanotify.services.ivc_champva.template_id.form_10_10d_email }
let(:expected_personalisation) do
data.slice(:first_name, :last_name, :file_count, :pega_status, :date_submitted, :form_uuid)
end
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected_personalisation is built with data.slice(...), but the service under test builds personalisation via %i[...].index_with { |k| data[k] }, which intentionally includes keys even when they’re missing from data (nil values). There are real call sites that omit first_name/last_name (e.g., the Pega alert payload builders), so this spec won’t catch regressions where the nil keys are dropped. Update the expectation to mirror the index_with behavior and add a case covering a payload missing optional keys.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarahwcodes can you take a look at this?

@rmtolmach
Copy link
Copy Markdown
Contributor

@sarahwcodes small merge conflict.

@sarahwcodes sarahwcodes enabled auto-merge (squash) April 22, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants