Repository navigation
fix(email): restore two-arg luxon fromObject in matchTeamIntro timeslots - #64
Open
detail-app[bot] wants to merge 1 commit into
Open
detail-app[bot] wants to merge 1 commit into
detail-app[bot] wants to merge 1 commit into
Conversation
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.
Detail bug report: View on Detail
Bug
The match-team intro email (
src/email/templates/matchTeamIntro.ts) silently dropped its "Suggested Meeting Times (all students available)" block for any matched team whose students actually supplied weekly availability data, falling back to the generic "Mentors: Send a When2meet" prompt instead.Root cause:
localIntervalToUtcbuilt each luxonDateTimewithDateTime.fromObject({ …, zone: tz })— placingzoneinside the values object. Under the installed runtimeluxon@3.7.2this throwsInvalidUnitError: Invalid unit zone(zoneis not a valid unit there; luxon 3.x takes the zone via a second options argument). A broadtry/catchinfindCommonTimeslotsswallowed the throw and returned{}, whichgetListcollapsed toundefined, so the template's{{#if commonTimeslots}}branch never rendered.This slipped through typecheck because
@types/luxonwas pinned to a stale^1.26.5whosefromObjectsignature accepts the extrazonekey, masking the runtime/types mismatch — and through testing because the code had no test coverage at all.Fix
DateTime.fromObject(values, { zone })form for both thestartandendconversions inlocalIntervalToUtc— the form the original feature commit used before the regression.@types/luxonfrom^1.26.5to^3.7.5so the type definitions match the^3.7.2runtime. This both lets the correct two-arg form typecheck and turns the buggy single-arg form into a compile error (TS2345: 'zone' does not exist in type 'DateObjectUnits'), preventing the identical regression from reoccurring. The whole repo still typechecks cleanly against the upgraded types.findCommonTimeslotstry/catchin place; the throw it was masking is gone, and a regression test now asserts noconsole.warnis emitted for valid data.matchTeamIntro.test.ts, stubbed Prisma) covering the core regression, cross-timezone UTC conversion, the swallowed-error guard, the legitimate-empty fallback, and both template branches.Testing
npx tsc --skipLibCheck --noEmit), and the existing unrelated offline test (syncAlumniInteractions.test.ts) all pass. (ESLint is broken environment-wide — eslint 7's parser is incompatible with the installed TS 5.x — and is not a usable signal here.)npx tsx src/email/templates/matchTeamIntro.test.ts) verifies: overlapping same-timezone availability yields a populatedcommonTimeslots; cross-timezone overlap (NY 9–11am / LA 6–8am, both 14:00–16:00 UTC) renders the window in each student's own timezone; no "finding common timeslots" warning is emitted for valid data; missingtimeManagementPlanlegitimately yieldsundefined; and the actualmatchTeamIntro.mdHandlebars block renders the "Suggested Meeting Times" block (not When2meet) when data is supplied, and the When2meet fallback (not the timeslot block) when it isn't.postgresql-16, created atestdatabase, applied the schema viaprisma db push, seeded a matched project with two accepted students in distinct timezones and overlapping availability plus an accepted mentor on amatchCompleteevent, and ran the real dispatch path (getEmailGenerators()→generator.getList()→generator.template()with the app's Handlebars helpers registered). The rendered email body contained the "Suggested Meeting Times" header with both timezone-labeled windows and no When2meet fallback; after clearing the students' plans, it rendered the When2meet fallback instead. Seed data was cleaned up afterward.fromObject({ …, zone })form producesTS2345compile errors under the upgraded types, so the build now blocks reintroduction.Automatic Fixes PRs can be configured here.