isomerpages / isomercms-backend

A static website builder and host for the Singapore Government
5 stars 1 forks source link

Is 166 race condition when editing a page inside a deleted folder #755

Closed kishore03109 closed 1 year ago

kishore03109 commented 1 year ago

Problem

User A creates a folder A

User A creates a page testPage inside folder A

User B starts editing page testPage

User A deletes folder A

User B saves page testPage

Observed behaviour:

Folder A exists, but is no longer accessible in the CMS. (404 error thrown)

Solution

Do a read call to ensure that the page still exists before making and mutation to the repo in github. Modifying the file just makes the user see the 404 page, and they have to navigate back to their workspace, which, while annoying, preserves the valid state of the repo.

Limitations

Since we are working with stale data, one would need to do a read call to make sure that the file exists in the particular folder. This would incur an additional call, but the hunch here is that the user will call this endpoint lesser than a window refresh.

Breaking Changes

kishore03109 commented 1 year ago

Closing for a better solution