Skip to content

fix(inbound): keep email.received events under the EventBridge size limit - #197

Merged
stewartjarod merged 1 commit into
mainfrom
fix/inbound-event-size
Oct 21, 2026
Merged

stewartjarod merged 1 commit into
mainfrom
fix/inbound-event-size

Conversation

@stewartjarod

Copy link
Copy Markdown
Contributor

What

The inbound Lambda (packages/core/lambda/inbound-processor) put the whole parsed email into the email.received EventBridge detail. A large mail could exceed the PutEvents entry limit, so PutEvents failed, the Lambda retried, and the mail never reached the consumer even though raw/ and parsed/ were already in S3.

  • Limit: 1 MB per entry since 2026-01-29 (PutEvents size, What's New); 256 KB still in ap-southeast-5/6/7, ap-east-2, mx-central-1, and assumed for GovCloud. Measured as UTF-8 bytes the way AWS counts.
  • Small mail: unchanged, byte for byte the same detail as parsed/{emailId}.json.
  • Oversized mail: fields are dropped whole until the entry fits: html, text, headers (largest first), then attachments (attachmentCount kept), then to/cc (counts kept, subject cut to 1,000 chars), then a bounded envelope. Every trimmed detail carries truncated: true, truncatedFields and parsedS3Key so consumers can fetch the full JSON.
  • FailedEntryCount > 0 (a failed entry inside a 200) now throws, so the Lambda retries instead of silently losing the event.
  • Docs: events reference and inbound quickstart pages; packages/core/CLAUDE.md (also fixes its env var list).

Found by a real round trip of @byo-oss/support's inbound path through a Wraps inbound stack.

Checks

  • pnpm --filter @wraps/core test: 13 files, 172 passed (inbound-processor 24, up from 16)
  • pnpm --filter @wraps/core typecheck, pnpm --filter wraps-website typecheck: clean
  • Lambda bundle rebuilt with pnpm --filter @wraps/core build:lambda (the other bundles came out byte-identical)

Follow-ups (not in this PR)

  • wraps-js packages/email/README.md handler example: text/html can be null when truncated is set; fetch parsedS3Key.
  • A retry still writes new parsed//attachments/ objects under a new emailId (pre-existing).

🤖 Generated with Claude Code

https://claude.ai/code/session_015wXo12iE7EnsbdjDvgqR1B

…imit

The inbound Lambda put the whole parsed email in the EventBridge detail. A large mail could exceed the PutEvents entry limit (1 MB; 256 KB in ap-southeast-5/6/7, ap-east-2, mx-central-1 and GovCloud), so the Lambda failed and retried while the mail never reached the consumer. Oversized details now drop html, text and headers (then attachments, then recipients) with truncated, truncatedFields and parsedS3Key, so consumers can fetch the full parsed JSON from S3. Small mail is sent unchanged. A FailedEntryCount > 0 response now throws so the Lambda retries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015wXo12iE7EnsbdjDvgqR1B
@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
wraps-web Building Building Preview Oct 21, 2026 5:25pm UTC
wraps-website Building Building Preview Oct 21, 2026 5:25pm UTC

Request Review

This branch was successfully deployed

2 active deployments
Preview – wraps-web — eeb23aa1 Deployed Oct 21, 2026 by vercel[bot]
Preview – wraps-website — eeb23aa1 Deployed Oct 21, 2026 by vercel[bot]
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