Skip to content

fix: allow null content_id in inbound email attachments#255

Merged
sweetmantech merged 1 commit intotestfrom
sweetmantech/myc-4395-api-inbound-email-content_id-error
Mar 3, 2026
Merged

fix: allow null content_id in inbound email attachments#255
sweetmantech merged 1 commit intotestfrom
sweetmantech/myc-4395-api-inbound-email-content_id-error

Conversation

@sweetmantech
Copy link
Contributor

@sweetmantech sweetmantech commented Mar 3, 2026

Summary

  • Resend sends content_id: null for regular file attachments (mp3s, etc.) — only inline attachments (embedded images) have a string content_id
  • The Zod schema in validateInboundEmailEvent was rejecting these payloads with a 400 error, preventing the webhook from processing emails with file attachments
  • Changed content_id: z.string() to content_id: z.string().nullable() to accept null values

Test plan

  • Added validateInboundEmailEvent.test.ts with 4 tests covering: no attachments, string content_id, null content_id, and invalid payload
  • Verified null content_id test fails before fix (RED)
  • Verified all tests pass after fix (GREEN)
  • Sidney to re-send test email with mp3 attachments to confirm end-to-end

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved email attachment handling to support attachments without content identifiers, enhancing compatibility with various email formats.

Resend sends content_id: null for regular file attachments (e.g. mp3s).
Only inline attachments have a string content_id. The Zod schema was
rejecting these payloads with a 400 error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Mar 3, 2026 9:01pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fb08b0 and d35dde9.

⛔ Files ignored due to path filters (1)
  • lib/emails/__tests__/validateInboundEmailEvent.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (1)
  • lib/emails/validateInboundEmailEvent.ts

📝 Walkthrough

Walkthrough

A schema validation change to allow null values for the content_id field in email attachments. The resendAttachmentSchema now accepts string | null instead of strictly string, updating the inferred ResendEmailData type accordingly.

Changes

Cohort / File(s) Summary
Email Attachment Schema
lib/emails/validateInboundEmailEvent.ts
Modified resendAttachmentSchema to make content_id nullable. The field now accepts z.string().nullable() instead of z.string(), updating the ResendEmailData type signature to reflect attachments[].content_id: string | null.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A field grows flexible, now it can be null,
Attachments whisper "maybe" down the hall,
No strings attached, just possibilities,
Content IDs dance—or skip—with ease. 🎭✨

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Solid & Clean Code ✅ Passed Pull request exemplifies SOLID principles and clean code practices with minimal, focused schema change that maintains single responsibility and respects composition patterns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sweetmantech/myc-4395-api-inbound-email-content_id-error

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@sweetmantech sweetmantech merged commit 36d385e into test Mar 3, 2026
3 checks passed
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