fix: keep reading back legacy transmission ids (2.8.1) - #21
Open
voj-tech-j wants to merge 2 commits into
Open
voj-tech-j wants to merge 2 commits into
voj-tech-j wants to merge 2 commits into
Conversation
An id handed out before Lettr held scheduled emails itself is answered from delivery events, in a shape with no `sch_` id. ScheduledEmail::from() read request_id unconditionally, so RequestId rejected the empty string and getScheduled() threw for that whole path - 2.8.0 fixed sch_ ids and broke this one in the same change. requestId now falls back to the transmission id, which is the id the caller addressed the email with, so it is always the id that identifies what you asked about. Found by running the example-rust suite against the same endpoint in the Rust client, which hit the identical flaw. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The legacy read path reports the provider's vocabulary, not Lettr's: a delivered email comes back state "delivered", which is not one of the five ScheduledEmailState cases, so ::from() threw ValueError. Verified against the live API, which answers "delivered" for an id that has delivery events. The existing legacy test used state "sent" — valid in both vocabularies, which is exactly why it missed this. It now uses "delivered", and an unrecognised value resolves to Unknown so a state added later cannot break reads again. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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.
A bug I shipped in 2.8.0.
getScheduled()now throws for legacy transmission ids:What happened
The API keeps an old-shape fallback for ids handed out before Lettr held scheduled emails itself: those are answered from delivery events, and that response has no
request_id.ScheduledEmail::from()read it unconditionally, soRequestIdrejected the empty string. 2.8.0 fixed reading backsch_ids and broke the legacy path in the same change.requestIdnow falls back totransmission_id, which is the id the caller addressed the email with — so it is always the id that identifies what you asked about. A test covers the full legacy payload.Who this affects
Anyone calling
getScheduled()with a transmission id stored before the API change, whose delivery events are still inside the 10-day retention window. Narrow and closing, but the API supports that path deliberately, so the SDK should too.sch_ids,schedule(),cancelScheduled()andlistScheduled()are unaffected.How it was found
Running the
example-rustsuite against the live API while porting the same change to the Rust client — itsget_scheduledtest uses a legacy id. The Rust client had the identical flaw; it's fixed there in lettr-rust#21, which is still open.Notes
304 tests pass, PHPStan and Pint clean.
CHANGELOG.mdandVERSIONare in this PR rather than a separatechore:one, since it's a one-line patch — happy to split if you'd rather keep the convention.🤖 Generated with Claude Code