Repository navigation
Conversation
…ts workflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rite changes a template rewrite_email_asset_url saved message template content directly, so a transactional template's workflow kept its old copy. Template saves from the API, the design patch and the rewrite now share one locked save-and-sync path in services/template_saves.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d draft Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A draft saved before a rewrite kept the old URL, and publishing it brought that URL back. The rewrite now finds and rewrites draft_content too. A draft-only rewrite saves the draft alone and writes no workflow version, because sends never read the draft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
force-pushed
the
fix/rewrite-email-asset-url-sync
branch
from
October 31, 2026 09:14
d6af733 to
6b455d0
Compare
🤖 CI report
|
| File | Comment lines | Added lines |
|---|---|---|
products/messaging/backend/services/template_saves.py |
7 | 76 |
products/messaging/backend/services/message_templates.py |
3 | 31 |
products/messaging/backend/services/transactional_email.py |
1 | 10 |
products/workflows/backend/management/commands/rewrite_email_asset_url.py |
1 | 31 |
This check does not block merging. It updates on every push and clears when the share drops.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rl rewrites The command rewrote workflows first, so by the time a transactional template synced its workflow the actions already matched and no new version was written. Message templates now run first, in every run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- when message templates are rewritten in the same run, the hog_flows pass rewrites only the drafts of workflows linked to a live template, so a template that fails keeps its workflow on the old URL and a rerun writes the new URL as a new version - save_locked_template takes an already-changed template; access checks and the change stay in save_template - --dry-run says it skips the sendability check - the new messaging code carries no docstrings or comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- the hog_flows pass leaves only the workflows of templates this run matched to the template rewrite, so a drifted workflow or a run with --id <workflow id> rewrites the workflow's live actions - restore the comments and facade docstrings the template save move kept applicable Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e sync - the hog_flows pass protects the workflows of templates whose published content holds the old url, found before the run; a template matched only by its draft never syncs, so its workflow's live actions get rewritten in place Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pass - the hog_flows pass reads which workflows a template content rewrite syncs once the template pass is done, so a template deleted during the run no longer keeps its workflow's live actions on the old url - name the facade lookup after the rule it encodes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Moved to PostHog#127295. |
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.
Moved here from #118965, closed on 2026-10-25 so this fork stack is the only copy. It opens upstream again after review.
This revision
43333f81da9on 2026-10-31. Master added template tags in the same view and service; the API update now writes them through the shared save path, and6b455d0d27tests a save with tags and other fields.044401fec2names the draft-only save of a rewrite.cc06f9d913: the command now rewritesmessage_templatesbeforehog_flows, whatever order--targetsgives. Before, a default run rewrote the workflow in place first, so the template's sync found nothing to change and the workflow kept its version.9ad607cdf3,6b4248a7e8,ea7ba66dfaanda62991ca21, QA swarm 2026-11-01:hog_flowspass rewrites only the draft of a workflow whose live template's published content still holds the old URL when the pass starts. A template that fails keeps its workflow on the old URL, and a rerun writes the new URL as a new workflow version.--id <workflow id>run, still gets its live actions rewritten in place, as before this PR.save_locked_templatetakes an already-changed template; the access check and the change stay insave_template.--dry-runhelp says it skips the check that a transactional template can still send.Problem
rewrite_email_asset_url, a transactional template's sends can keep the old asset URL.--targets message_templatesor--id <template id>. A default run rewriteshog_flowsin place, so sends get fixed there, but the workflow gets no new version.Impact
Keeps transactional sends on the asset URL their template shows, after an operator moves an asset. Not measured; the command runs by hand. Expected move: none on a metric. Run cost: n/a.
Merge Danger
Caution
🔴 Merge risk: high · two-way door (merge-risk rubric)
Changes
services/template_saves.py: the API update, the design patch, and the rewrite command. It locks the template row, checks the workflow-editor permission, checks the template can still send, saves, and syncs the workflow.draft_content, added in feat(workflows): draft and publish edits to transactional email templates PostHog/posthog#118664). Before, a draft saved before a rewrite kept the old URL, and publishing it brought that URL back.--list-rowsand the summaries follow that order.--dry-runskips the check that a transactional template can still send: that check runs while the workflow version is built, which a dry run never writes.lock_transactional_workflow_id,check_transactional_update,update_templateandedit_content_lockedare gone. Nothing else called them.Rebase note
services/template_saves.pyuses the file, names and signatures #548 planned for the same orchestration. #548 is closed, so a later PR that adds a write intent or a content hash extends these functions. PostHog#118664's draft save keeps its own path, and a content save through the shared path still clears the draft.How did you test this code?
Test rationale: one case in
TestTransactionalEmail(products/messaging/backend/tests/api/test_transactional_email.py) catches a rewrite that saves the template without syncing its workflow. The closest existing test,test_saving_a_transactional_template_writes_a_new_workflow_version, covers the API update only. The rewrite command tests inproducts/workflows/backend/test/test_rewrite_email_asset_url.pynever make a template transactional.rewrite_template_content, the messaging facade function the command calls for message templates, and the command itself for drafts.TestRewriteEmailAssetUrl(products/workflows/backend/test/test_rewrite_email_asset_url.py) catches a rewrite that skips a template whose draft alone holds the URL. Red before the fix: the command matched 0 rows.test_a_run_writes_one_new_version_of_a_transactional_templates_workflowintest_rewrite_email_asset_url.pyruns the real command twice, with the default targets and with--targets hog_flows,message_templates, and expects version 2 with the new URL. Red beforecc06f9d913(assert 1 == 2).test_a_failed_template_leaves_its_workflow_for_a_rerun_to_versionfails a template on an unverified sender, then reruns: version 1 with the old URL after the failure, version 2 with the new URL after the rerun. Red before9ad607cdf3: version 1 with the new URL.test_rewrites_a_transactional_workflow_whose_template_content_lacks_the_urlcovers a default run, a--id <workflow id>run, and a template whose draft alone holds the old URL, each with a workflow whose live actions still hold it. Red before6b4248a7e8andea7ba66dfa: the workflow kept the old URL.test_rewrites_the_workflow_of_a_template_deleted_during_the_rundeletes the template in place of its rewrite. Red beforea62991ca21: the workflow kept the old URL.assert 1 == 2).87d1b6befe: the rewrite command, template API and transactional email tests (128 passed), ruff, and the commit hook's ruff, format and ty checks.Live run
rewrite_email_asset_urlon a local database, each template made transactional first. URLs arehttps://assets.example.com/{old,new}.png.--id A--id B, row written by base code--targets message_templates, row written by HEADA second run covers a transactional template whose draft alone holds
https://assets.example.com/draft-old.png.--id A--id BNot run: the plugin server, so the worker reload after commit was not observed. It is scheduled with
on_commit, as the API save already does.Proofs (per
qa-swarmPROOF.md)Follow-ups
--from-urlwould make that visible.Release status
Docs update
None. The command's behavior is documented in its own help text, which is unchanged.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Claude Opus 5.5 (claude-opus-5-5)
tdd,/writing-tests,/writing-pr-descriptions,pr-description,modernize-pr,merge-risk.example.comURLs).Decisions
template_saves.pynames and signatures, so the rebase is a straight conflict resolution--targetssays, so the template sync writes the workflow versionInvolvement: no grilling rounds, no prototypes. Review: one GPT-6.1 Sol review (high effort) on
c90e0ca, no findings; one note on sender reuse corrected this description. Final GPT-6.1 Sol reads (high effort) of the rebase onto PostHog#118664 and of the draft rewrite found nothing. After the restack: GPT-6.1 Sol round 1 (one finding on the target order, fixed test-first) and a clean read of the fix. QA swarm on 2026-11-01: full panels in rounds 2 and 3 and a fixes panel in round 4 (GPT-6.1 Sol review lanes, Claude Opus 5.5 fresh eyes), every finding fixed test-first or answered, then final reads. Proof: live run captured on an earlier head.🤖 Generated with Claude Code