Skip to content

feat: surface round-robin subset host info in no-slots admin email and add logging#28593

Draft
joeauyeung wants to merge 2 commits intomainfrom
devin/1774562297-no-slots-rr-subset-clarity
Draft

feat: surface round-robin subset host info in no-slots admin email and add logging#28593
joeauyeung wants to merge 2 commits intomainfrom
devin/1774562297-no-slots-rr-subset-clarity

Conversation

@joeauyeung
Copy link
Copy Markdown
Contributor

@joeauyeung joeauyeung commented Mar 26, 2026

What does this PR do?

When org admins receive the "no available slots" notification email, it now clearly indicates if a round-robin host subset (rrHostSubsetIds) was being used for the booking request. This helps admins understand that the lack of availability may be because only a restricted subset of RR hosts were considered, rather than all hosts being unavailable.

Additionally, structured logging is added around the no-slots notification flow for better observability.

Changes:

  • handleNotificationWhenNoSlots.ts: Accepts optional rrHostSubsetIds, adds two log.info calls (one when handling the notification, one per email sent) with relevant context (username, eventSlug, teamId, orgDomain, subset IDs). Logs use recipientType instead of email addresses to avoid PII in logs.
  • Email templates (TSX + plaintext): Conditionally render an RR subset notice section when rrHostSubsetIds is present and non-empty. Both HTML and plaintext bodies use the same i18n key (org_admin_no_slots|rr_subset_notice) for consistent localization. The plaintext body also adds an extra possible-cause bullet about restrictive subsets.
  • slots/util.ts: Passes input.rrHostSubsetIds through to the notification service call.
  • i18n: New org_admin_no_slots|rr_subset_notice translation key.
  • Tests: 3 new test cases covering subset IDs provided, not provided, and empty array.

Updates since last revision:

  • Removed admin.user.email from log output (PII concern flagged by Cubic AI review) — replaced with recipientType: "org-admin"
  • Plaintext email body now uses the org_admin_no_slots|rr_subset_notice i18n key instead of a hardcoded English string, keeping localization consistent with the HTML template

Visual Demo

N/A — server-rendered email template, no UI changes visible in the app.

Mandatory Tasks

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Set UPSTASH_REDIS_REST_TOKEN and UPSTASH_REDIS_REST_URL env vars.
  2. Ensure an org has adminGetsNoSlotsNotification enabled.
  3. Hit a team event type's availability endpoint with rrHostSubsetIds query param pointing to user IDs that have no availability.
  4. After 2 no-slot occurrences, the admin email should include the RR subset notice section mentioning the specific user IDs.
  5. Verify logs contain [noSlotsNotification] entries with the expected fields (no email addresses in log output).

Unit tests: TZ=UTC yarn vitest run packages/features/slots/handleNotificationWhenNoSlots.test.ts — all 12 tests pass.

Important review notes

  • The email displays raw user IDs (e.g., "user IDs: 10, 20, 30") — this matches the intent of surfacing the technical subset info for admins to debug. If usernames are preferred, that would require an additional DB lookup.
  • Import reordering in email files and import process from "node:process" additions are from biome auto-fix (lint-staged), not manual changes.
  • input.rrHostSubsetIds ?? undefined in slots/util.ts coerces a potential null from the input schema to undefined for the notification service interface.

Human review checklist

  • Verify the org_admin_no_slots|rr_subset_notice i18n interpolation ({{userIds}}) renders correctly in both HTML and plaintext email paths
  • Confirm log.info noise level is acceptable — notification is throttled to once per 7 days per user/event combo, so volume should be low
  • Confirm displaying raw user IDs (rather than usernames) is the desired UX for org admins

Link to Devin session: https://app.devin.ai/sessions/b34d10bee15b482a9eba64adb14edd25
Requested by: @joeauyeung

…d add logging

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/features/slots/handleNotificationWhenNoSlots.ts">

<violation number="1" location="packages/features/slots/handleNotificationWhenNoSlots.ts:134">
P1: Custom agent: **Avoid Logging Sensitive Information**

Avoid Logging Sensitive Information: do not write `admin.user.email` to logs. This emits PII for every notification email sent; log a non-PII marker instead.</violation>
</file>

<file name="packages/emails/templates/organization-admin-no-slots-email.ts">

<violation number="1" location="packages/emails/templates/organization-admin-no-slots-email.ts:40">
P2: Reuse the existing `org_admin_no_slots|rr_subset_notice` translation in the plaintext body so the new section is localized consistently with the HTML email.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session


✅ Pushed commit 71e132c

…ext email

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant