Modify a change note in Publishing API, Content Publisher or Whitehall
We are sometimes asked to amend change notes, for example where a user has made a typo. This playbook describes how to amend change notes in Whitehall, Content Publisher and Publishing API.
Whitehall
Whitehall supports modifying change notes directly from the UI. The feature is hidden from publishers, but available to anyone with GDS Admin
permissions.
2nd-line Content Support team can modify the change note themselves:
- Append
/change_notes
to the URL of the admin screen, for example:https://whitehall-admin.publishing.service.gov.uk/government/admin/editions/<edition-id>/change_notes
- You may need to replace the portion after
/admin/
with the wordeditions
. For example,https://whitehall-admin.publishing.service.gov.uk/government/admin/publications/1389309/change_notes
won’t work, buthttps://whitehall-admin.publishing.service.gov.uk/government/admin/editions/1389309/change_notes
will.
Adding a change note is not yet supported in the UI. You can use the Rails console, for example:
ed = Edition.where(id: <relevant id>).first
ed.state = "draft"
ed.save
ed.update(minor_change: false, change_note: "Change note", major_change_published_at: Time.new(2022,12,21))
ed.save
ed.state = "published"
ed.save
Content Publisher
Content Publisher has a set of rake tasks for adding, deleting and editing change notes.
Specialist Publisher
Use the Publishing API procedure below.
Other Publishing Apps
The other publishing apps do not yet provide a way to update a change note.
Use the app’s Rails console to update the change history in the app’s own database, then republish the document via the app’s web UI.
Publishing API
⚠️ You should use the relevant publishing app to modify a change note where possible. Only use publishing-api where a publishing app lacks support for updating change notes.
Obtain kubectl credentials for the EKS cluster. Follow the set up guide if unfamiliar.
Open a Rails console on Publishing API:
k exec -it deploy/publishing-api -- rails c
Find the document:
document = Document.find_by_content_id("YOUR_CONTENT_ID_HERE")
Find the document’s live edition:
live_edition = document.editions.live.last
Fetch the edition’s details change history:
live_edition.details[:change_history]
If this is empty, follow method A. Otherwise, follow method B.
Method A: update an individual ChangeNote
Fetch the change notes for the document:
change_notes = ChangeNote.joins(:edition).where(editions: { document: document }).order(:public_timestamp)
Retrieve the change note to amend, for example by searching for the note text:
note = change_notes.find_by("note LIKE ?", "%SUBSTRING OR FULL CHANGE NOTE TEXT%")
Update the change note:
note.update(note: "NEW NOTE")
Send the document downstream using the content ID.
Method B: update details.change_history
Fetch the details for the edition:
details = live_edition.details
View the change history:
details[:change_history]
Retrieve the change note to amend, for example by searching for the note text:
change_note_index = details[:change_history].find_index { |change_note| change_note[:note] =~ /SUBSTRING OR FULL CHANGE NOTE TEXT/ }
Check the returned change note is correct:
details[:change_history][change_note_index]
Update the change note:
details[:change_history][change_note_index][:note] = "New note"
Update the edition:
live_edition.update(details: details)
Send the document downstream using the content ID.
Troubleshooting
Change note is in content item in Whitehall and publishing-api but not showing on page
Content Store may be out of sync with Publishing API.
- If the problem is only in staging/integration and not production, check for failed environment sync jobs for content-store or publishing-api.
- Check the Sidekiq monitoring queue to see if the document is stuck somewhere in a queue.
- Look in Kibana for responses with
status:409
(resource conflict). This can indicate that content-store already has a more recent version of the document than publishing-api. - Compare the
payload_version
in publishing-api and content-store in the Rails console. Content Store will reject the request if the the request’spayload_version
is not newer than the one in the content-store database. See also content-data-api: Processing publishing-api messages: Discarding messages.