Skip to content

Commit 2a797e8

Browse files
Don't assert human error message in TestAsyncUpload (de-flake) (#839)
As a general rule, we should not be asserting the language of human `error` messages. They can change at any time, localized, etc. This is spawning from a real life flaky failure I'm seeing when testing with the workers variant of Synapse: ```shell $ WORKERS=1 COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh ./tests/csapi -run TestAsyncUpload/Cannot_upload_to_a_media_ID_that_has_already_been_uploaded_to ... === NAME TestAsyncUpload/Cannot_upload_to_a_media_ID_that_has_already_been_uploaded_to media_async_uploads_test.go:68: MatchResponse key 'error' got 'Media ID cannot be overwritten' (type string) want 'Media ID already has content' (type string) - http://127.0.0.1:33651/_matrix/media/v3/upload/hs1/GjRDDFucigeiLQtzNbjADIoI => {"errcode":"M_CANNOT_OVERWRITE_MEDIA","error":"Media ID cannot be overwritten"} 2026/01/22 17:05:44 ============================================ --- FAIL: TestAsyncUpload (14.13s) --- FAIL: TestAsyncUpload/Cannot_upload_to_a_media_ID_that_has_already_been_uploaded_to (0.07s) FAIL FAIL github.com/matrix-org/complement/tests/csapi 16.063s FAIL ``` I also see this test listed in the known flakes we track with Synapse: element-hq/synapse#18537 This problem happens because there are two possible error messages in Synapse which we could encounter for `M_CANNOT_OVERWRITE_MEDIA`: - [`"Media ID already has content"`](https://github.com/element-hq/synapse/blob/826a7dd29aea7041fb25b98d360da4dbedf22712/synapse/media/media_repository.py#L304-L308) - [`"Media ID cannot be overwritten"`](https://github.com/element-hq/synapse/blob/826a7dd29aea7041fb25b98d360da4dbedf22712/synapse/rest/media/upload_resource.py#L159-L163)
1 parent 86f2b6a commit 2a797e8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tests/csapi/media_async_uploads_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestAsyncUpload(t *testing.T) {
4242
StatusCode: http.StatusGatewayTimeout,
4343
JSON: []match.JSON{
4444
match.JSONKeyEqual("errcode", "M_NOT_YET_UPLOADED"),
45-
match.JSONKeyEqual("error", "Media has not been uploaded yet"),
45+
match.JSONKeyPresent("error"),
4646
},
4747
})
4848
})
@@ -64,7 +64,7 @@ func TestAsyncUpload(t *testing.T) {
6464
StatusCode: http.StatusConflict,
6565
JSON: []match.JSON{
6666
match.JSONKeyEqual("errcode", "M_CANNOT_OVERWRITE_MEDIA"),
67-
match.JSONKeyEqual("error", "Media ID already has content"),
67+
match.JSONKeyPresent("error"),
6868
},
6969
})
7070
})

0 commit comments

Comments
 (0)