Commit 2a797e8
authored
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
0 commit comments