Skip to content

[WHIT-2842] Fix draft locale deletion bug in Publishing API#11012

Merged
ChrisBAshton merged 2 commits into
mainfrom
fix-draft-locale-deletion
Jan 21, 2026
Merged

[WHIT-2842] Fix draft locale deletion bug in Publishing API#11012
ChrisBAshton merged 2 commits into
mainfrom
fix-draft-locale-deletion

Conversation

@MuriloDalRi
Copy link
Copy Markdown
Contributor

@MuriloDalRi MuriloDalRi commented Jan 16, 2026

What & Why

When changing the primary locale of a draft (e.g. from English to French), the draft for the previous locale was not being discarded in Publishing API, leaving orphaned drafts.

  • Captures dirty attributes in EditionService before reload.
  • Passes previous primary locale to PublishingApiPusher.
  • Upates PublishingApiPusher to discard the previous locale draft during update_draft event if the primary locale has changed.
  • Adds regression tests in DraftLocaleSwitchTest.

Jira: https://gov-uk.atlassian.net/browse/WHIT-2842

@MuriloDalRi MuriloDalRi changed the title Fix draft locale deletion bug in Publishing API [WHIT-2842] Fix draft locale deletion bug in Publishing API Jan 16, 2026
@MuriloDalRi MuriloDalRi force-pushed the fix-draft-locale-deletion branch 5 times, most recently from bfcca2b to dfa858b Compare January 16, 2026 18:05
When changing the primary locale of a draft (e.g. from English to
French), the draft for the previous locale was not being discarded in
Publishing API, leaving orphaned drafts.

This commit:
- Captures dirty attributes in `EditionService` before reload.
- Passes the previous primary locale to `PublishingApiPusher`.
- Upates `PublishingApiPusher` to discard the previous locale draft
  during `update_draft` event if the primary locale has changed.
- Adds regression tests in `DraftLocaleSwitchTest`.

Jira: https://gov-uk.atlassian.net/browse/WHIT-2842
@ChrisBAshton ChrisBAshton force-pushed the fix-draft-locale-deletion branch from dfa858b to 86832ca Compare January 19, 2026 14:36
@ChrisBAshton ChrisBAshton marked this pull request as ready for review January 19, 2026 14:36
Copy link
Copy Markdown
Contributor

@ryanb-gds ryanb-gds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion to consider, which hopefully might make this a little less complicated if I'm correct

Comment thread app/services/service_listeners/publishing_api_pusher.rb Outdated
Copy link
Copy Markdown
Contributor

@ryanb-gds ryanb-gds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any danger in discarding the translation before we update the draft in Publishing API? If the latter fails the preview will be missing but feels like quite a small risk?

Approving on basis that risk is probably minimal, don't merge if you disagree 🙈

@ChrisBAshton ChrisBAshton merged commit 1104c0e into main Jan 21, 2026
25 checks passed
@ChrisBAshton ChrisBAshton deleted the fix-draft-locale-deletion branch January 21, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants