Skip to content

Report the NULL-plan send backstop in email_usage_get - #641

Merged
kentcdodds merged 2 commits into
mainfrom
cursor/auto-username-email-inbox-8ab0
Jul 6, 2026
Merged

kentcdodds merged 2 commits into
mainfrom
cursor/auto-username-email-inbox-8ab0

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Small follow-up to #635, found while running the post-deploy migration audit.

When the username-based email model merged, email_sends_per_day joined nullPlanEmailFallbackLimits (100/day backstop for plan-less users) — but #636's email_usage_get landed in parallel with a hardcoded assumption that plan-less sends are unlimited, so it reports sends_today.limit: null while enforcement actually caps at 100. Observed live right after the deploy:

"sends_today": { "count": 0, "limit": null }

Fix: resolve the send limit through resolveEmailResourceLimit like the other email resources, so the usage surface matches enforcement. Updated the workers test expectation accordingly.

npm run validate green locally (the only test-expectation change is the NULL-plan sends_today.limit).

System recap — composes existing primitives (low risk)

Mode: recap · Base: main @ 858befed · Head: c8f605a5

Classification: composes — one capability read path aligned with the entitlement enforcement that already shipped; no primitive contracts change.

Primitives touched

Primitive Group Impact
email assistant composes — email_usage_get reports the existing send backstop
entitlements auth composes — read-only use of resolveEmailResourceLimit

System map

flowchart LR
	mcpServer["mcp-server"]:::untouched
	email["email"]:::touched
	entitlements["entitlements"]:::touched
	mcpServer -->|"email_usage_get"| email
	email --> entitlements
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Improved email usage limits so daily send counts now display a consistent fallback limit when no plan is available.
    • Updated the email usage response to better reflect send quota information for accounts without an assigned plan.

email_sends_per_day joined nullPlanEmailFallbackLimits when the
username-based email model landed, so plan-less users are capped at the
deployment backstop rather than unlimited. email_usage_get still
reported limit: null for them; use resolveEmailResourceLimit so the
usage surface matches enforcement.
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-641.kentcdodds.workers.dev

Worker: kody-pr-641
D1: kody-pr-641-db
KV: kody-pr-641-oauth-kv

Mocks:

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cad91330-9501-4803-9ec3-e033aacb012c

📥 Commits

Reviewing files that changed from the base of the PR and between 858befe and c8f605a.

📒 Files selected for processing (2)
  • packages/worker/src/mcp/capabilities/email/email-usage-get.ts
  • packages/worker/src/mcp/capabilities/email/email-usage-get.workers.test.ts

📝 Walkthrough

Walkthrough

The email usage capability's sends_today.limit calculation was simplified to always call resolveEmailResourceLimit(plan, 'email_sends_per_day'), removing conditional logic and the unused resolvePlanLimit import. The corresponding test was updated to expect the fallback limit value for null-plan users instead of null.

Changes

Email send limit resolution

Layer / File(s) Summary
Simplify limit resolution and update test
packages/worker/src/mcp/capabilities/email/email-usage-get.ts, packages/worker/src/mcp/capabilities/email/email-usage-get.workers.test.ts
Replaces conditional plan ? resolvePlanLimit(...) : null logic with an unconditional resolveEmailResourceLimit call, removes the now-unused import, and updates the null-plan test to expect the fallback limit instead of null.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • kentcdodds/kody#619: Introduces the entitlements/quota system with null-plan fail-open semantics that this PR's limit resolution builds on.
  • kentcdodds/kody#635: Introduces nullPlanEmailFallbackLimits.email_sends_per_day, directly used by this PR's updated test expectation.
  • kentcdodds/kody#636: Related change to email_usage_get logic and plan-less send limit handling.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: reporting the NULL-plan email send backstop in email_usage_get.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/auto-username-email-inbox-8ab0

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.

@kentcdodds
kentcdodds merged commit befa400 into main Jul 6, 2026
5 checks passed
@kentcdodds
kentcdodds deleted the cursor/auto-username-email-inbox-8ab0 branch July 6, 2026 14:45
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.

2 participants