ENG-3301: Refactor messaging dispatchers into provider classes (Story 1)#7947
Closed
ENG-3301: Refactor messaging dispatchers into provider classes (Story 1)#7947
Conversation
Replace the function-based dispatcher pattern in message_dispatch_service.py with provider classes behind a two-level ABC hierarchy: - BaseMessageProviderService → BaseEmailProviderService / BaseSMSProviderService - 5 provider classes: MailgunService, TwilioEmailService, AwsSesService, MailchimpTransactionalService, TwilioSmsService - PROVIDER_MAP routes MessagingServiceType to provider classes - dispatch_message() signature unchanged — all callers unaffected Key changes: - Delete ~315 lines of old dispatcher functions, validate_config, and helpers - Move SES validate_email_and_domain_status() from per-send to config-time (advisory warning in update_config_secrets, not blocking) - Delete old src/fides/service/messaging/aws_ses_service.py - TwilioSmsService overrides validate_config() for secrets-only validation - SES tests rewritten with moto[ses] instead of unittest.mock patches - Add moto[ses] to dev dependencies Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Dependency Review✅ No vulnerabilities found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (74.79%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #7947 +/- ##
==========================================
- Coverage 85.06% 84.13% -0.94%
==========================================
Files 629 634 +5
Lines 40860 41045 +185
Branches 4748 4768 +20
==========================================
- Hits 34759 34533 -226
- Misses 5029 5365 +336
- Partials 1072 1147 +75 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Constant was only used by deleted dispatcher functions. Test import updated to pull from twilio_email_service where it's actively used. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket ENG-3301
Description Of Changes
Refactors the function-based dispatcher pattern in
message_dispatch_service.py(~315 lines removed) into provider classes behind a two-level ABC hierarchy. This is PR 1 of 3 for ENG-3301 — it covers the structural refactor only (Story 1). Threading headers (Story 2) and correspondence scaffolding (Story 3) follow in separate PRs.What changed:
BaseMessageProviderService→BaseEmailProviderService/BaseSMSProviderService_*_dispatcherfunctions:MailgunService,TwilioEmailService,AwsSesService,MailchimpTransactionalService,TwilioSmsServicePROVIDER_MAProutesMessagingServiceType→ provider classdispatch_message()signature is unchanged — all callers (fides + fidesplus) are unaffectedIntentional behavioral improvement:
validate_email_and_domain_status()moved from per-send to config-time (advisory warning inupdate_config_secrets). SES itself rejects sends from unverified identities (MessageRejected), making the per-send check redundant. See plan Decision Port CI from GitLab CI to GitHub Actions #11 for rationale.Test improvements:
moto[ses]instead ofunittest.mockpatches — exercises real boto3 client construction through motomoto[ses]to dev dependencies (moto[s3]→moto[s3,ses])Reference: Based on patterns from Eli Rosselli's
LJ-352-improvementsbranch (~Feb 2025, never merged), with divergences documented in the technical plan.Code Changes
src/fides/api/service/messaging/messaging_providers/package — ABC base + 5 provider classesmessage_dispatch_service.py— replaced dispatcher functions withPROVIDER_MAP+_resolve_provider_map(), deleted ~315 linesmessaging_endpoints.py— wired advisory SES validation intoupdate_config_secrets()src/fides/service/messaging/aws_ses_service.py— replaced by newAwsSesServiceproviderpyproject.toml—moto[s3]→moto[s3,ses]_*_dispatcherfunctions to new provider classesSteps to Confirm
tests/ops/service/messaging/+tests/service/messaging/)test_integration_dynamic_erasure_email.py,test_integration_attentive.py,test_integration_generic_email.py) collect without import errorsdispatch_message()signature unchanged — verify no fidesplus import breakagePre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works