From 311ae0e8fccf12bab8024c01c177ccc53aef1f21 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Tue, 7 Jul 2026 09:45:02 +0000 Subject: [PATCH 1/3] Revert "Fix flaky 3PID inhibit error unit tests (#19913)" This reverts commit c7a47bc121382869cb7b3a551494366890f19998. --- changelog.d/19913.misc | 1 - tests/rest/client/test_account.py | 10 +--------- tests/rest/client/test_register.py | 3 --- tests/server.py | 5 +---- tests/unittest.py | 4 ---- 5 files changed, 2 insertions(+), 21 deletions(-) delete mode 100644 changelog.d/19913.misc diff --git a/changelog.d/19913.misc b/changelog.d/19913.misc deleted file mode 100644 index 31b5a4d37b9..00000000000 --- a/changelog.d/19913.misc +++ /dev/null @@ -1 +0,0 @@ -Fix a flake in 3PID inhibit error unit tests, causing occasional failures in CI. \ No newline at end of file diff --git a/tests/rest/client/test_account.py b/tests/rest/client/test_account.py index 158d7f33f0d..42102230f00 100644 --- a/tests/rest/client/test_account.py +++ b/tests/rest/client/test_account.py @@ -325,13 +325,7 @@ def test_password_reset_bad_email_inhibit_error(self) -> None: email = "test@example.com" client_secret = "foobar" - session_id = self._request_token( - email, - client_secret, - # The endpoint intentionally adds up to 1000ms of jitter to avoid - # leaking whether the email address is bound to an account. - timeout_ms=3000, - ) + session_id = self._request_token(email, client_secret) self.assertIsNotNone(session_id) @@ -370,7 +364,6 @@ def _request_token( client_secret: str, ip: str = "127.0.0.1", next_link: str | None = None, - timeout_ms: int = 1000, ) -> str: body = {"client_secret": client_secret, "email": email, "send_attempt": 1} if next_link is not None: @@ -380,7 +373,6 @@ def _request_token( b"account/password/email/requestToken", body, client_ip=ip, - timeout_ms=timeout_ms, ) if channel.code != 200: diff --git a/tests/rest/client/test_register.py b/tests/rest/client/test_register.py index a9f3ac24627..f66c56a6b19 100644 --- a/tests/rest/client/test_register.py +++ b/tests/rest/client/test_register.py @@ -753,9 +753,6 @@ def test_request_token_existing_email_inhibit_error(self) -> None: "POST", b"register/email/requestToken", {"client_secret": "foobar", "email": email, "send_attempt": 1}, - # The endpoint intentionally adds up to 1000ms of jitter to avoid - # leaking whether the email address is already bound to an account. - timeout_ms=3000, ) self.assertEqual(200, channel.code, channel.result) diff --git a/tests/server.py b/tests/server.py index 15a7661c345..052f76d755e 100644 --- a/tests/server.py +++ b/tests/server.py @@ -459,7 +459,6 @@ def make_request( await_result: bool = True, custom_headers: Iterable[CustomHeaderType] | None = None, client_ip: str = "127.0.0.1", - timeout_ms: int = 1000, ) -> FakeChannel: """ Make a web request using the given method, path and content, and render it @@ -488,8 +487,6 @@ def make_request( custom_headers: (name, value) pairs to add as request headers client_ip: The IP to use as the requesting IP. Useful for testing ratelimiting. - timeout_ms: if `await_result` is `True`, the amount of time to wait on - the request before timing out. Ignored otherwise. Returns: channel @@ -574,7 +571,7 @@ def make_request( req.requestReceived(method, path, b"1.1") if await_result: - channel.await_result(timeout_ms=timeout_ms) + channel.await_result() return channel diff --git a/tests/unittest.py b/tests/unittest.py index 202f7120ef0..3d130c1d779 100644 --- a/tests/unittest.py +++ b/tests/unittest.py @@ -571,7 +571,6 @@ def make_request( await_result: bool = True, custom_headers: Iterable[CustomHeaderType] | None = None, client_ip: str = "127.0.0.1", - timeout_ms: int = 1000, ) -> FakeChannel: """ Create a SynapseRequest at the path using the method and containing the @@ -600,8 +599,6 @@ def make_request( client_ip: The IP to use as the requesting IP. Useful for testing ratelimiting. - timeout_ms: if `await_result` is `True`, the amount of time to wait on - the request before timing out. Ignored otherwise. Returns: The FakeChannel object which stores the result of the request. @@ -621,7 +618,6 @@ def make_request( await_result, custom_headers, client_ip, - timeout_ms, ) def setup_test_homeserver( From 928716e76af4887d8e66ad645d2f4bc6bf672e29 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 7 Jul 2026 10:50:38 +0100 Subject: [PATCH 2/3] Re-add comments from #19913 --- tests/rest/client/test_account.py | 6 ++++++ tests/rest/client/test_register.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/tests/rest/client/test_account.py b/tests/rest/client/test_account.py index 42102230f00..de4611fbf9a 100644 --- a/tests/rest/client/test_account.py +++ b/tests/rest/client/test_account.py @@ -325,6 +325,12 @@ def test_password_reset_bad_email_inhibit_error(self) -> None: email = "test@example.com" client_secret = "foobar" + + # Note: The endpoint intentionally adds up to 1000ms of jitter to avoid + # leaking whether the email address is bound to an account. + # + # This should be handled by `await_result` underneath, which has a + # 1000ms timeout. session_id = self._request_token(email, client_secret) self.assertIsNotNone(session_id) diff --git a/tests/rest/client/test_register.py b/tests/rest/client/test_register.py index f66c56a6b19..67f47830611 100644 --- a/tests/rest/client/test_register.py +++ b/tests/rest/client/test_register.py @@ -749,6 +749,11 @@ def test_request_token_existing_email_inhibit_error(self) -> None: ) ) + # Note: The endpoint intentionally adds up to 1000ms of jitter to avoid + # leaking whether the email address is bound to an account. + # + # This should be handled by `await_result` underneath, which has a + # 1000ms timeout. channel = self.make_request( "POST", b"register/email/requestToken", From b2d96f97dcdff4020df136a7fc2fb12f869fd03b Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 7 Jul 2026 10:51:28 +0100 Subject: [PATCH 3/3] newsfile --- changelog.d/19916.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/19916.misc diff --git a/changelog.d/19916.misc b/changelog.d/19916.misc new file mode 100644 index 00000000000..aeec5ae4128 --- /dev/null +++ b/changelog.d/19916.misc @@ -0,0 +1 @@ +Add note to 3PID email token request unit tests that the endpoint being tested can have an expected, artificial delay of up to 1s. \ No newline at end of file