Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the publishing step when trying to republish HTML attachments for unpublished documents #8780

Conversation

minhngocd
Copy link
Contributor

@minhngocd minhngocd commented Jan 30, 2024

The publishing of the HTML attachment could leave the document in a bad state and especially dangerous around sensitive documents where they should be unpublished, but are then inadvertently published during the republishing process.
We should be able to reapply the redirects for unpublishing without the need to publish the document first.
Withdrawn document process has been left as is for the moment.

https://trello.com/c/e75Mp1Ap/2301-investigate-if-we-can-avoid-temporary-publishing-of-html-attachments-during-republishing-of-unpublished-edition

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

Follow these steps if you are doing a Rails upgrade.

@minhngocd minhngocd force-pushed the remove-unpublishing-step-when-republshing-unpublished-or-withdraw branch 4 times, most recently from 94af7ed to bc60706 Compare January 30, 2024 20:35
…for unpublished documents

The publishing of the HTML attachment could leave the document in a bad state and especially dangerous around sensitive documents where they should be unpublished, but are then inadvertently published during the republishing process.
We should be able to reapply the redirects for unpublishing without the need to publish the document first.
Withdrawn document process has been left as is for the moment.
@minhngocd minhngocd force-pushed the remove-unpublishing-step-when-republshing-unpublished-or-withdraw branch from bc60706 to 630ab47 Compare January 30, 2024 20:45
@minhngocd minhngocd changed the title Remove the publishing step when trying to republish HTML attachments … Remove the publishing step when trying to republish HTML attachments for unpublished documents Jan 30, 2024
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.

A few comments for your consideration - sorry we didn't get a chance to pair on this as there is definitely enough complexity in this small PR to warrant it. Maybe let's jump on a call to discuss. Pretty sure everything is correct anyway but just want to confirm my understanding.

unpublish_if_required
if Edition::PRE_PUBLICATION_STATES.include?(edition.state)
update_draft(update_type: "republish")
elsif edition.unpublishing && edition.withdrawn?
Copy link
Contributor

Choose a reason for hiding this comment

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

Would just edition.withdrawn? be sufficient? I don't think you can have a withdrawn edition without an unpublishing... 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup I can apply this

do_publish("republish")
discard_drafts(deleted_html_attachments)
withdraw
elsif edition.unpublishing
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly we could use edition.unpublished? here, I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup I can apply this

publication = create(:unpublished_publication_in_error_no_redirect)
PublishingApiWorker.any_instance.expects(:perform).never
call(publication)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm personally not a huge fan of tests that test something doesn't happen, or at least not beyond an initial TDD cycle. Theoretically the set of things we could test don't happen is infinite so I always feel a bit dubious about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a documentation sense that we explicitly want to call out that publishing "should not" happen, then I think it should be tested for things that we definitely do not want to happen otherwise bad things happen. To prevent in the future if people do add that functionality back in, they can see the test and thing "hmm do i really want to do this"

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, I don't feel too strongly about it.

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.

I'll feel a good bit safer once this is deployed 🚀

Up to you if you want to do anything with the conditionals, I don't feel strongly about those either

@minhngocd
Copy link
Contributor Author

From further discussion in chats with @ryanb-gds, I think it would be good to merge this as is without the conditionals refactor to check state of edition instead of looking at the unpublishing association. We can have that done separately in another PR case it does have an impact

@minhngocd minhngocd merged commit 8f9a92f into main Jan 31, 2024
20 checks passed
@minhngocd minhngocd deleted the remove-unpublishing-step-when-republshing-unpublished-or-withdraw branch January 31, 2024 15:59
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.

2 participants