Repository navigation
fix(events): stamp the ICS feed's DTSTAMP and LAST-MODIFIED in UTC - #1161
Conversation
ical-generator renders those two properties through the CALENDAR timezone (`formatDate(this.calendar.timezone(), …)`), not the event's. Any non-null value sends `formatDate` down its local-components branch, which drops the `Z` and reads the hours off `getHours()` — the rendering host's clock, not the zone named there. RFC 5545 §3.8.7.2 and §3.8.7.3 require UTC for both. Setting `name: null` keeps the generator, and the VTIMEZONE set is built from the calendar zone plus every event's own zone, so the component Apple needs still ships. `DTSTART`, `DTEND` and `EXDATE` go through the event's zone and are unchanged. Two non-standard headers go with the name, `TIMEZONE-ID` and `X-WR-TIMEZONE`; nothing in this repo reads either. The spec's comment explained the missing `Z` as the calendar zone rendering every timestamp "in that zone". It was the host's zone: under TZ=America/Vancouver a 10:00Z LAST-MODIFIED rendered as 03:00, not London's 11:00. The new case pins the `Z` on both surfaces and fails under TZ=UTC too, where the old assertion was green. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXCZHrsVMDKFu1VAtN
The calendar zone also fed `RRULE;UNTIL` and, where the rule carries no TZID,
`DTSTART`/`DTEND`. Both were floating — no TZID and no `Z` — which a client
reads as its own local time. They are now UTC instants, and the spurious
VTIMEZONE a UTC zone generated, dated at the epoch, is gone.
Neither was pinned. `toContain('UNTIL=20260930')` matches the date part, which
is identical either way, so it could not tell the conformant UNTIL from the
floating one. Nothing covered the tzid-less path at all.
Also drops a claim that the new DTSTAMP case only bites under a non-UTC TZ. The
missing `Z` fails it under every host zone, and reading otherwise invites
deleting the one guard for this defect as vacuous.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXCZHrsVMDKFu1VAtN
|
🚅 Deployed to the SahajCloud-pr-1161 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
One production line, plus the assertions that pin it. As small as the problem allows, and the body's account of the library holds: formatDate takes its getHours() branch on any non-null zone (ical-generator/src/tools.ts:286), and calendar.ts:639 builds the VTIMEZONE set from the calendar zone plus every event's own, so dropping the name keeps the component Apple needs. The three joined assertions — UNTIL, the UTC-zone spelling, DTSTAMP on both surfaces — pin other outputs of that same line, so they join rather than smuggle. Nothing this repo or a sibling reads moved: TIMEZONE-ID and X-WR-TIMEZONE have no reader in src/, tests/ or docs/. One gap: the fix closes the instance and leaves the class open.
Findings
should-fix— the lane pins noTZand CI runs UTC, so the next host-clock assertion lands green again.tests/unit/ics-builder.spec.ts:330.
What was checked
- Read
icsBuilder.tsandics-builder.spec.tswhole on the branch, plus both callers (calendarFeed.ts:204,sendRegistrationConfirmation.ts:70) —buildEventCalendaris the onlyical-generatorentry point in the repo. - Walked the ladder: the diff adds no file, helper, type or dependency.
{ name: null, generator }is the library's own shape, not a workaround. - Verified the before/after in the library, not from the body:
formatDateTZreadsTZIDoffdata.timezone, so a UTC event'sDTSTARTreally was floating. CREATEDalso renders through the calendar zone; this builder never sets it.- Preview:
pr-1161.cloud-preview.sydevelopers.comanswers 302 to the Access login. This run holds no service token, so the preview is unreachable, not empty. - Measurement behind the finding:
TZ=Asia/Tokyo pnpm test:unitonmain— 1 failed, 281 files green.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The defect #1161 fixes renders correctly on a UTC host, so CI's UTC runner saw the right text and the assertion that pinned it stayed green for the whole life of the bug. Criterion 4 of #1158 — the spec passes under a non-UTC process timezone — was left to a hand-run `TZ=` prefix, which nothing repeats. Pinning `TZ` in `sharedTestEnv` makes the lane itself the guard. Watched failing: with the pin in place and no `TZ=` prefix, `main`'s pre-fix `icsBuilder.ts` and spec report 1 failed, 25 passed. Both lanes are green with it on this branch — unit 3878 in 282 files, int 1972 in 109 files. Asia/Tokyo rather than a DST zone: a constant whole-hour offset keeps a divergence unambiguous, and no case then depends on the date it runs. Raised in review: #1161 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVYptVDhw6qizzv8PQ
|
Pushed Adopted — the lane pins no
Lean gate: ✓. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
DTSTAMPandLAST-MODIFIEDare now UTC with aZ, in both the calendar feed and the registration-confirmation attachment, instead of the rendering host's wall clock.RRULE;UNTILand a tzid-less event'sDTSTART/DTENDwere floating times, and are now UTC instants. Neither was pinned by a test.Asia/Tokyo, so the class of defect behind all of the above fails CI instead of hiding behind a UTC runner.Change outline
Contract — what a calendar client receives
One line decides all of it.
ical-generatorrenders a different set of properties through the calendar zone than through the event zone, and only the first set was wrong.// src/lib/schedule/icsBuilder.ts ical({ - timezone: { name: timezone, generator: getVtimezoneComponent }, + timezone: { name: null, generator: getVtimezoneComponent }, })Rendered through the calendar zone — all fixed by that line:
Rendered through the event zone — unchanged, and asserted so:
An event whose rule carries no TZID falls back to
'UTC', and that path moves too — out of floating time, which a client reads as its own local time:Behaviour — why a non-null name was wrong
The zone argument is only a flag here: for a
Dateit is never applied, so the hours came from whatever machine rendered the document. The VTIMEZONE set is built from the calendar zone plus every event's own zone, so dropping the calendar's name keeps the component Apple needs.Guard — why the lane moved off UTC
Code reading the host clock where an instant is required renders the correct text on a UTC host. CI runs UTC, so the assertion that pinned
LAST-MODIFIEDstayed green for the whole life of the bug, and acceptance criterion 4 could only be met by aTZ=prefix someone remembers to type.// vitest.config.mts — sharedTestEnv, read by both the unit and int projects NODE_ENV: 'test', + TZ: 'Asia/Tokyo',Watched failing: with the pin in place and no
TZ=prefix,main's pre-fixicsBuilder.tsand spec report 1 failed, 25 passed —LAST-MODIFIED:20260801T190000against the expected…T100000.Asia/Tokyorather than a DST zone, so the offset is a constant whole hour and no case depends on the date it runs.Preview
Calendar feed URLfield is the.icsthis PR changesData: not seeded yet.
previewUrl.seedis unset for this repo, so nothing seeds a preview automatically, and both links open on an empty list until someone creates an event. The wire format is covered by the unit lane instead — see Manual verification for the one-minute hand check.Test results
tests/unit/ics-builder.spec.ts28 passed underTZ=UTC,TZ=America/VancouverandTZ=Asia/Tokyo;tests/int/event-calendar-feed.int.spec.ts22 passedsharedTestEnvreaches it too: 1972 passed in 109 files under the pinEvery new assertion was watched failing against the reverted line, under
TZ=UTCandTZ=Asia/Tokyo: 4 failed, 24 passed in both.Manual verification
The acceptance criteria are covered by the unit lane. What it cannot reach is a real client parsing the document:
Calendar feed URLand subscribe to the.icsin Apple Calendar and Google Calendar.Notes for reviewer
DTSTART/DTEND/EXDATEstayTZID-qualified. For a zoned event they do, and that is asserted. For an event whose zone resolves toUTCthey are now…Zinstants with noTZID, because RFC 5545 spells UTC that way and never asTZID=UTC. They were floating before, so nothing regressed — but it is a spelling change the criterion does not literally cover.TIMEZONE-IDandX-WR-TIMEZONE. Both are non-standard, andgrepfinds no reader in this repo. They go with the calendar name; keeping them would mean keeping the defect.comment-lintfindings — both "points at a section number". They citeRFC 5545 §3.3.10and§3.8.7.x. The code-comments rule names an RFC as a fine breadcrumb; the linter cannot tell a published RFC's section from a project doc's. Each comment also states the rule in full, so it survives its link being cut./code-review highpass found 3 issues, all fixed inc293574, which is also where the joined UNTIL and UTC-zone coverage lives.Detail
Why not pass the zone through instead.
formatDateignores the zone argument for aDate— it only branches on whether it is null. There is no value that yields "render in Europe/London with an offset"; the only correct output for these properties is UTC, which is what RFC 5545 §3.8.7.2 and §3.8.7.3 require anyway.Why the old assertion was green on CI. It pinned
LAST-MODIFIED:20260801T100000with noZ, and CI runs UTC, so the host clock agreed with the intended value. UnderTZ=America/Vancouverthe same input rendered20260801T030000. The spec's comment attributed this to the calendar zone rendering "in that zone" — had that been true the value would have been London's11:00, not Vancouver's03:00.Why
UNTILneeded a stronger assertion. It readtoContain('UNTIL=20260930'). The date part is identical before and after, so it passed against both the floating and the UTC spelling and could not catch a revert.Measurement note. An early reading of this branch suggested a tzid-less
DTSTARTwas emitted at the epoch. That was an unscopedstartsWith('DTSTART')matching the VTIMEZONE's own transition line — the trap the spec'svevent()helper documents. The epoch date is real, but it belongs to the spurious UTC VTIMEZONE, which this change removes.Closes #1158
🤖 Written by the sydevs autonomous loop — see what this is