Skip to main content
Warning This document has not been updated for a while now. It may be out of date.
Last updated: 20 Jun 2022

Whitehall Attachment Stuck in Uploading State

In rare cases, typically when a user has uploaded a large archive of multiple files, the Whitehall backend can become stuck and not correctly update the uploading status of the file.

This results in the user being unable to publish an edition due to the Whitehall frontend being convinced that the upload is still ongoing, despite any evidence to the contrary.

The following needs access to the Whitehall’s Admin Panels.

If you can not download the file from the draft edition, or it is corrupted, you will have to ask the user to upload a new version of the file. You may have to replace the file in Asset Manager if this new version is also acting as if it is corrupted.

Steps to fix

If you can download the file and open it without issue from the draft edition in Whitehall’s Admin Panels then the best course of action is the following:

  1. SSH into the Whitehall backend machine and open a terminal into the rails app itself using govuk_app_console whitehall.

  2. Use attachment = AttachmentData.find(*attachmentid*) to grab the attachment object into a variable.

  3. Check that the attachment is not marked as uploaded using attachment.uploaded_to_asset_manager? and have it return false.

  4. Reset its status using attachment.uploaded_to_asset_manager! and repeat step 3 to ensure it is now returning true. This is potentially dangerous and should only be done if you can download the uncorrupted file. Test it on integration first!

The list of files should show the attachment as uploaded now, and allow publication.

Why this works

It is unknown how this can occur, but essentially for large enough files, the backend will not update the upload status correctly, leaving it as nil.

As a result, we will mark the uploading status as still ongoing, even if it’s complete. Running the aforementioned function simply sets the uploaded status to complete.

This does not actually check the file status, so it is important that you check the file is downloadable and not corrupted before you run the function.