Overview
As a first small step towards #3587587 we should start detecting conflicts during the polling of auto-save endpoint.
More specifically, conflicts that are caused by updating entity for which there is already an auto-save entry in Canvas.
Current openapi definition of the auto-saves/pending endpoint only describes a HTTP 200 response.
That is correct, as ApiAutoSaveController::get() does not perform validation or conflict detection and currently only returns HTTP 200 responses.
This issue aims to change that by adding ability to detect certain types of conflicts and respond with HTTP 409.
This will allow Canvas UI to be notified about a conflict, even if the user is not performing any actions that would previously trigger a conflict detection.
Proposed resolution
- Add
openapidefinition for HTTP 409 response from theauto-saves/pendingendpoint. - Start storing "original hash" during auto-save entry save, as this allows us to detect if the underlying entry has been updated since and there is a conflict between what auto-save assumes about the entity and the actual entity state.
- Make AutoSaveManager to check for conflicts during fetching of the auto-save entry list, add relevant conflict metadata (
conflictIdandtimestamp) to the entries. - Make
ApiAutoSaveController::get()check entries for Page entities in the list and respond with HTTP 409 if at least one such entry has a conflict - As we will be making it possible to recover from some of detected conflicts, on conflicts caused by the change of the underlying auto-save entry entity we will return HTTP 409 and the response body will contain both:
errorwith a new error code for errors describing auto-save entries with conflictsdatawith all the auto-save entries, including the entries with detected conflicts (thanks to #3588038: Refactor auto-save endpoint response to encapsulate entries in top-level "data" key, like JSON:API, to enable adding errors later)
- Add tests for all of this as well as update any existing tests that might start break due to unexpected HTTP 409
User interface changes
For brief period of time until #3585970: UI changes for detection of conflicts caused by external updates to underlying entity of auto-save entry is merged there will be a possibility to encounter a situation where Canvas UI forces to refresh the page based on the conflict detection during auto-save endpoint polling.
No other UI changes are introduced in this issue.
Issue fork canvas-3589076
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wim leersLovely precise issue, thanks! 🤩
This could live either under the component or the component. But based on the plan, the key changes are .
So changing to the other issue queue component to ensure @tedbow reviews this.