Skip to content

[Bug] Unhandled GitHub errors can cause unintended drifts #583

@dcshzj

Description

@dcshzj

Describe the bug
The CMS currently does not handle all GitHub errors, which can cause an inconsistent state in the GitHub repository for the site, which can cause confusion for the end user.

This was first reported in the moe-ast-moehc repository, where the Isomer army member attempted to move a collection of over 500 files at once.

This is an excerpt of the error received:

Nov  9 10:08:41 ip-172-31-51-8 web: 2022-11-09 18:08:41 Wed Nov 09 2022 10:08:41 GMT+0000 (Coordinated Universal Time): {
    "name": "NotFoundError",
    "status": 404,
    "message": "File does not exist",
    "isIsomerError": true,
    "stack": "NotFoundError: File does not exist\n    at GitHubService.read (/var/app/current/src/services/db/GitHubService.js:86:36)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5)\n    at async SubcollectionPageService.read (/var/app/current/src/services/fileServices/MdPageServices/SubcollectionPageService.js:53:42)\n    at async SubcollectionPageService.updateSubcollection (/var/app/current/src/services/fileServices/MdPageServices/SubcollectionPageService.js:154:9)\n    at async SubcollectionDirectoryService.renameDirectory (/var/app/current/src/services/directoryServices/SubcollectionDirectoryService.js:107:7)\n    at async CollectionsRouter.renameCollectionDirectory (/var/app/current/src/routes/v2/authenticatedSites/collections.js:102:7)"
}

Possible solutions
2 possible solutions come to mind, but will require more investigation:

  1. Before updating the collection.yml file, a final sanity check should be performed to ensure that all the files are actually moved and the old folder is no longer existent. If there are still files in the old folder, the move should be retried.
  2. More generally, the NotFoundError thrown here is uncaught, and encountering this error should be an indicator that there is an issue somewhere that should be resolved. In this case, we should catch the error and retry the move.

Additional context
Relevant thread on Slack

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions