Fix S2B generator: preview letters pushed to translation then removed on generate - #2146
Merged
Merged
Conversation
Copilot created this pull request from a session on behalf of
ecino
September 2, 2026 14:14
View session
ecino
approved these changes
Sep 3, 2026
ecino
marked this pull request as ready for review
September 3, 2026 05:26
Confidence Score: 5/5No blocking failure remains. The exercised manual-validation and preview-to-final flows route final S2B letters through local translation when the field office does not support the source language.
What T-Rex did
Reviews (3): Last reviewed commit: "T3404 Fix S2B generator: prevent preview..." | Re-trigger Greptile |
ecino
force-pushed
the
copilot/fix-s2b-correspondence-issue
branch
from
September 3, 2026 05:53
b2b43e0 to
e33d00a
Compare
… translation and removed on generate - Skip Draft letters in create() so that preview does not trigger translation dispatch or commkit creation. - Delete any Draft (preview) letters for a sponsorship before generating for real, forcing them through the create() path which correctly handles translation/commkit dispatch.
ecino
force-pushed
the
copilot/fix-s2b-correspondence-issue
branch
from
September 3, 2026 06:41
e33d00a to
9636a26
Compare
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.
S2B letters written in a language the child cannot read were pushed to the translation platform then immediately removed when using the Preview → Generate workflow.
Two compounding bugs:
sbc_translationcreate()dispatched all new S2B letters (includingDraft/preview) to the translation platform. Clicking "Preview" incorrectly queued the letter for translation.generate_letters_jobfound existing Draft letters viaself.letter_idsand calledletter.write(vals)— resettingstateto"Received in the system"and silently pulling the letter out of the translation queue without re-dispatching.The discrepancy between local and staging: local test data typically doesn't require translation (
original_lang in language_ids), so letters took thecreate_commkit()path and the bug was never exposed. Staging with real data hits the translation path every time.Changes
sbc_translation/models/correspondence.py— skipDraftletters increate():sbc_compassion/models/correspondence_s2b_generator.py— delete existing Draft letters before non-preview generation so they go throughcreate(), which correctly handles translation/CommKit dispatch: