feat: surface round-robin subset host info in no-slots admin email and add logging#28593
Draft
joeauyeung wants to merge 2 commits intomainfrom
Draft
feat: surface round-robin subset host info in no-slots admin email and add logging#28593joeauyeung wants to merge 2 commits intomainfrom
joeauyeung wants to merge 2 commits intomainfrom
Conversation
…d add logging Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
There was a problem hiding this comment.
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.
Contributor
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. ✅ Pushed commit |
…ext email Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 optionalrrHostSubsetIds, adds twolog.infocalls (one when handling the notification, one per email sent) with relevant context (username, eventSlug, teamId, orgDomain, subset IDs). Logs userecipientTypeinstead of email addresses to avoid PII in logs.rrHostSubsetIdsis 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: Passesinput.rrHostSubsetIdsthrough to the notification service call.org_admin_no_slots|rr_subset_noticetranslation key.Updates since last revision:
admin.user.emailfrom log output (PII concern flagged by Cubic AI review) — replaced withrecipientType: "org-admin"org_admin_no_slots|rr_subset_noticei18n key instead of a hardcoded English string, keeping localization consistent with the HTML templateVisual Demo
N/A — server-rendered email template, no UI changes visible in the app.
Mandatory Tasks
How should this be tested?
UPSTASH_REDIS_REST_TOKENandUPSTASH_REDIS_REST_URLenv vars.adminGetsNoSlotsNotificationenabled.rrHostSubsetIdsquery param pointing to user IDs that have no availability.[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
import process from "node:process"additions are from biome auto-fix (lint-staged), not manual changes.input.rrHostSubsetIds ?? undefinedinslots/util.tscoerces a potentialnullfrom the input schema toundefinedfor the notification service interface.Human review checklist
org_admin_no_slots|rr_subset_noticei18n interpolation ({{userIds}}) renders correctly in both HTML and plaintext email pathslog.infonoise level is acceptable — notification is throttled to once per 7 days per user/event combo, so volume should be lowLink to Devin session: https://app.devin.ai/sessions/b34d10bee15b482a9eba64adb14edd25
Requested by: @joeauyeung