Skip to content

Record why an email send was rejected or failed - #132

Merged
sidneyswift merged 1 commit into
mainfrom
codex/email-send-reason
Nov 7, 2026
Merged

sidneyswift merged 1 commit into
mainfrom
codex/email-send-reason

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a nullable reason column to email_send_log, so a rejected or failed POST /api/emails attempt records why.

Why

Most logged sends (59% in the August investigation on recoupable/app#1949) were rejected, and the log could not say why: the rejected path stored only the raw body, and the earlier error column was dropped in 20260630211500 because nothing filled it. The companion api PR writes reason as a short code then detail (recipient_not_allowed: …, invalid_body: html: …, no_account_email, auth_failed: 401, resend_error: …), so the rejection rate can be grouped by cause.

Notes

  • Additive and nullable; existing rows and writers are unaffected.
  • Merge and apply this before the api PR that writes the column.

🤖 Generated with Claude Code


Summary by cubic

Adds a nullable reason column to email_send_log so rejected or failed POST /api/emails attempts can record why.

Written for commit 675e45a. Summary will update on new commits.

View guided diff Turn on auto-fix

Adds email_send_log.reason so the rejected path (59% of logged sends)
can be grouped by cause. Written by api logEmailAttempt as a short code
then detail, e.g. "recipient_not_allowed: a@example.com".

Refs recoupable/app#1949

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be0a1698-c5a2-48f1-aded-a5d4b7c89415
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@supabase

supabase Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Updates to Preview Branch (codex/email-send-reason) ↗︎

Deployments Status Updated
Database ✅ Sat, 07 Nov 2026 04:16:27 UTC
Services ✅ Sat, 07 Nov 2026 04:16:27 UTC
APIs ✅ Sat, 07 Nov 2026 04:16:27 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations ✅ Sat, 07 Nov 2026 04:16:28 UTC
Migrations ✅ Sat, 07 Nov 2026 04:16:32 UTC
Seeding ✅ Sat, 07 Nov 2026 04:16:32 UTC
Edge Functions ✅ Sat, 07 Nov 2026 04:16:32 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="supabase/migrations/20261106120000_email_send_log_reason.sql">

<violation number="1" location="supabase/migrations/20261106120000_email_send_log_reason.sql:10">
P3: `reason` combines the cause code and the per-send detail (such as a recipient address) in one free-text value. A plain `GROUP BY reason` will split rejections by recipient, not by cause. Consider separate `reason_code` and `reason_detail` columns, or document the `split_part(reason, ': ', 1)` grouping for analysts. The column is not yet populated, so changing it now is cheap.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

-- followed by detail, e.g. `recipient_not_allowed: a@example.com`, so the
-- rejection rate can be grouped by cause. Null for successful sends.

ALTER TABLE public.email_send_log ADD COLUMN IF NOT EXISTS reason TEXT;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: reason combines the cause code and the per-send detail (such as a recipient address) in one free-text value. A plain GROUP BY reason will split rejections by recipient, not by cause. Consider separate reason_code and reason_detail columns, or document the split_part(reason, ': ', 1) grouping for analysts. The column is not yet populated, so changing it now is cheap.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At supabase/migrations/20261106120000_email_send_log_reason.sql, line 10:

<comment>`reason` combines the cause code and the per-send detail (such as a recipient address) in one free-text value. A plain `GROUP BY reason` will split rejections by recipient, not by cause. Consider separate `reason_code` and `reason_detail` columns, or document the `split_part(reason, ': ', 1)` grouping for analysts. The column is not yet populated, so changing it now is cheap.</comment>

<file context>
@@ -0,0 +1,10 @@
+-- followed by detail, e.g. `recipient_not_allowed: a@example.com`, so the
+-- rejection rate can be grouped by cause. Null for successful sends.
+
+ALTER TABLE public.email_send_log ADD COLUMN IF NOT EXISTS reason TEXT;
</file context>

@sidneyswift
sidneyswift merged commit ebdb549 into main Nov 7, 2026
16 checks passed
sidneyswift added a commit to recoupable/mono that referenced this pull request Nov 8, 2026
Records the merged monthly-onboarding and missed-report work:
recoupable/database#132, recoupable/api#1235 and #1236, and
recoupable/app#2392, #2393 and #2394, plus whatever else landed on those
mains since the last recorded commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant