instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.41k stars 2.42k forks source link

Impossible to replace a file with an older version #2309

Closed sattlerc closed 5 months ago

sattlerc commented 5 months ago

Summary:

Since the 2024-01-17 update, it is impossible to replace a file with an older version.

Steps to reproduce:

  1. Prepare two files with same name N, but different contents X and Y.
  2. Upload file N with content X.
  3. Upload file N with content Y, choosing to overwrite.
  4. Upload file N with content X, choosing to overwrite.

Expected behavior:

All file uploads happen successfully, overwriting the respective previous version.

Actual behavior:

Step 4 fails with Error: Request failed with status code 404. This happens in the user interface as well as the REST API.

The actual file upload happens successfully, but the location returned references the obsolete file id from step 2, which of course no longer exists.

Additional notes:

This took some time to debug. We started experiencing random file replacement uploads starting at 2024-01-17. After a while, it became clear that this occurred when uploading old file versions, leading to the above test case.

Going through the relevant commits from the release on 2024-01-17, the commit triggering this behaviour seems to be this one: 94bf50edc58 ("reuse attachment when reuploading to the same folder"). The search for an existing identical attachment seems to return an obsolete attachment, leading to the 404 "not found" error.

@jstanley0 @Ardena