cloud: accept the team API's millisecond timestamps
main is red on macos / swift-package-tests and this is why.
TeamsClient.decoder set dateDecodingStrategy = .iso8601, which rejects
fractional seconds. Every team date on the wire is written by
Date.toISOString(), which always emits milliseconds:
web/services/teams/received.ts:56expiresAt: row.expiresAt.toISOString()web/services/teams/invitations.ts:34expiresAt: invitation.expiresAt.toISOString()web/services/teams/links.ts:38,40createdAtandexpiresAt
So team detail, sent invitations, received invitations and invite links could
not decode at all. This is a production decode failure, not a test-fixture
problem, and the three red tests in TeamsClientModelsTests were reporting it
correctly.
The fix parses the fractional shape first and falls back to whole seconds,
matching VMClient.dateValue in the same package. Date.ISO8601FormatStyle
is Sendable where ISO8601DateFormatter is not, so it can live on the static
decoder. A string that is not a date still throws.
Tests
Two commits: the pinning test first, then the fix.
decodesFractionalSecondTimestamps asserts the exact instants for the
millisecond shape, that whole-second strings decode to the same instants, and
that a non-date string still fails, so widening to two shapes does not become
accepting anything.
Verified before pushing by compiling TeamsClientModels.swift plus the lifted
decoder and every assertion from the four tests in this suite with swiftc on
Linux:
- with the
.iso8601decoder from main: 3 failures, identical to CI
(dataCorrupted ... codingPath: [invitations, Index 0], "Expected date string to be ISO8601-formatted.") - with this change: 19/19 assertions pass
Parsing was checked against 2026-10-05T12:00:00.000Z,
2026-10-05T12:00:00Z, 2026-10-05T12:00:00.123456Z,
2026-10-05T12:00:00+00:00 and not-a-date, and a null optional date
confirmed not to reach the strategy at all.
This is a fix, so it skips team review.
— Raindrop g2 🫧
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Fixes TeamsClient date decoding so team dates with millisecond timestamps no longer fail to decode, which was breaking team detail, invitations, and invite links and turning macos / swift-package-tests red on main.
- Replaces the
.iso8601strategy with a custom one that parses fractional seconds first and falls back to whole seconds, matchingVMClient.dateValue; non-date strings still throw. - Adds a test pinning the millisecond, whole-second, sub-second, dated invite link, and non-date wire shapes.
Summary by CodeRabbit
- Bug Fixes
- Improved handling of timestamps in team details: dates with or without fractional seconds now decode, while invalid date values continue to produce a decoding error.