Skip to content

feat: add SendGrid destination - #194

Merged
masukai merged 3 commits into
drt-hub:mainfrom
PFCAaron12:feat/add-SendGrid-destination
Apr 12, 2026
Merged

feat: add SendGrid destination#194
masukai merged 3 commits into
drt-hub:mainfrom
PFCAaron12:feat/add-SendGrid-destination

Conversation

@PFCAaron12

Copy link
Copy Markdown
Collaborator

What does this PR do?

  1. Add SendGridDestinationConfig to drt/config/models.py

  2. Create drt/destinations/sendgrid.py

  3. Register the new config in DestinationConfig union in models.py

  4. Wire it in drt/cli/main.py _get_destination()

  5. Add tests in tests/unit/test_sendgrid.py using a FakeSendGridDestination

Related Issue

Closes #36

Checklist

  • Tests pass (make test)
  • Linter passes (make lint)
  • Updated CHANGELOG.md (if user-facing change)

@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@masukai masukai left a comment

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.

Thanks for the contribution @PFCAaron12! 🙌

A SendGrid destination is a great addition. I have a few items that need to be addressed before we can merge:

1. Config model is incomplete

SendGridDestinationConfig is missing fields that the implementation relies on: from_email, from_name, subject_template, body_template, list_ids. Currently the code uses hasattr() / getattr() to check for them at runtime, but drt uses Pydantic models as the source of truth — all fields should be declared explicitly.

See how DiscordDestinationConfig handles this in drt/config/models.py for reference.

2. Tests don't exercise the real implementation

FakeSendGridDestination overrides load() entirely, so the actual SendGridDestination.load() is never called. Tests should mock httpx.Client (like tests/unit/test_discord.py does) rather than replacing the destination class.

3. CLA

Please sign the CLA by posting a comment:

I have read the CLA Document and I hereby sign the CLA

4. Minor

  • Missing newline at end of sendgrid.py and test_sendgrid.py

Happy to answer any questions — looking forward to the next revision! 🚀

@masukai masukai mentioned this pull request Apr 5, 2026
3 tasks
@masukai

masukai commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Apologies for the delay. I’m away for a few days but will prioritize this when I’m back.

@PFCAaron12

Copy link
Copy Markdown
Collaborator Author

I have made the changes.

@PFCAaron12

Copy link
Copy Markdown
Collaborator Author

I have read the CLA Document and I hereby sign the CLA.

masukai
masukai previously approved these changes Apr 12, 2026

@masukai masukai left a comment

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.

Thanks for the quick revisions, @PFCAaron12 — and for submitting both this and #195! Really appreciate you helping expand drt's destination coverage at this early stage. 🙌

The config model rewrite and test improvements are solid — much better than the first version.

A few things I noticed that I'll clean up post-merge (no action needed from your side):

  • Import sortingruff check --fix will sort these automatically. Tip: running make fmt locally before pushing catches these.
  • Trailing newline at end of files — most editors can add this automatically (e.g., VS Code: files.insertFinalNewline)
  • resolve_env() helper — the codebase has a shared helper for resolving auth tokens from env vars (drt/config/credentials.py). I'll swap in the standard pattern.
  • auth field type — I'll narrow it to BearerAuth for fail-fast validation, and a few other minor consistency tweaks.

Merging with squash — thanks again for the contribution! 🎉

If you enjoy using drt, a ⭐ on the repo would mean a lot. Happy to see more PRs from you!

PFCAaron12 and others added 3 commits April 12, 2026 21:37
- Use resolve_env() for auth token resolution
- Narrow auth field to BearerAuth (fail-fast validation)
- Add describe() method to SendGridDestinationConfig
- Fix load() signature to use DestinationConfig (Protocol compliance)
- Add on_error="fail" break support within batch loop
- Use sync_options.retry with _DEFAULT_RETRY fallback
- Use json.dumps(row, default=str) for safe record preview
- Remove list_ids from mail/send payload (not supported by API)
- Use explicit default arg in do_post() closure
- Add CHANGELOG entry
- Fix trailing newlines, import ordering (ruff)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@masukai
masukai force-pushed the feat/add-SendGrid-destination branch from c499614 to 45ef409 Compare April 12, 2026 12:41
@masukai
masukai merged commit a10ff48 into drt-hub:main Apr 12, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

good first issue: add SendGrid destination (send email per row)

2 participants