Return success from publish command when document already has a published edition and no draft exists #3068
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously the publish command raised a conflict error in this case.
However, this error was rarely useful to the Publishing apps, as in almost all cases it is caused by publishing apps having to do their own dependency resolution due to shortcomings in Publishing API's dependency resolution, or by Sidekiq's "at least once" job running guarantees.
We therefore return a success response from the publish command and perform a no-op in this situation, rather than return an HTTP 409 error response for the publishing app to handle.
Why
This causes occasional errors in Whitehall which trigger Sentry alerts. Whilst we could ignore 409 responses in Whitehall, it seems sensible to make a change on the Publishing API side. From a RESTful API perspective the request has been successful in that the document is in the published state.
For further discussion see this Trello card: https://trello.com/c/h7xkpcUj and Slack thread
This will require an accompanying PR to update the Pact tests for Publishing API: alphagov/gds-api-adapters#1319