Skip to content

Conversation

@patrickpatrickpatrick
Copy link
Contributor

@patrickpatrickpatrick patrickpatrickpatrick commented Dec 12, 2025

What

  • Add link_set to ConfigurableDocumentLinks
  • Update patch_links in PublishingApi to call link_set (if presenter has method defined)

Why

A support ticket came in that raised an issue of associations persisting across the different types of News Article. This is because when a draft edition is updated, the PATCH endpoint for links is called. This creates a link_set of the links of the edition. The creation of the link_set means that even if subsequent PUT requests are made with a new set of links, the links associated with the link_set of the document will persist. Therefore we need to include empty array for each association that the document does not utilize. When we do this, the association will be cleared from the content item and so can't be accessed by the frontend rendering applications.

Implementation details

I did try and destructively remove the associations on the edition itself. The problem with this though is that an association can have a different name to how it is called on the edition. ministerial_roles is role_appointments, so without some of way of mapping the name change there wasn't a way to do this programmatically.

Personally, I quite like the non-destructive approach since it means the document can be switched back and forth and not need to be refilled in again.

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This application is owned by the Whitehall Experience team. Please let us know in #govuk-whitehall-experience-tech when you raise any PRs.

Follow these steps if you are doing a Rails upgrade.

@patrickpatrickpatrick patrickpatrickpatrick changed the title see if this works Handle links on change of type Dec 12, 2025
@patrickpatrickpatrick patrickpatrickpatrick changed the title Handle links on change of type Add link_set for updating links on StandardEdition update [WHIT-2828] Dec 12, 2025
Copy link
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.

Unfortunately I don't think this is going to work, because while it's ok for news articles, other standard edition types may not allow all of the available association types as part of their links object, and this will cause Publishing API to reject the request

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.

3 participants