Skip to content

Conversation

@MadLittleMods
Copy link
Collaborator

@MadLittleMods MadLittleMods commented Jan 22, 2026

Don't assert human error message in TestAsyncUpload (de-flake).

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:

$ 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:

Dev notes

How to run in element-hq/synapse-rust-apps:

COMPLEMENT_REF=madlittlemods/fix-media-async-upload-tests-not-being-independent COMPLEMENT_TEST_PACKAGES=./tests/csapi/... ./scripts-dev/complement.sh -run TestAsyncUpload/Cannot_upload_to_a_media_ID_that_has_already_been_uploaded_to

Pull Request Checklist

JSON: []match.JSON{
match.JSONKeyEqual("errcode", "M_NOT_YET_UPLOADED"),
match.JSONKeyEqual("error", "Media has not been uploaded yet"),
match.JSONKeyPresent("error"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, we do match.JSONKeyPresent("error") in a few other places. I think this can make sense in terms of making sure it's a standard Matrix error response.

@MadLittleMods MadLittleMods changed the title Don't assert human error message in TestAsyncUpload Don't assert human error message in TestAsyncUpload (de-flake) Jan 22, 2026
@MadLittleMods MadLittleMods marked this pull request as ready for review January 22, 2026 23:22
@MadLittleMods MadLittleMods requested review from a team as code owners January 22, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants