diff --git a/synapse/storage/util/sequence.py b/synapse/storage/util/sequence.py index 2ea1de4bfa..fbfa30b489 100644 --- a/synapse/storage/util/sequence.py +++ b/synapse/storage/util/sequence.py @@ -44,9 +44,9 @@ https://github.com/matrix-org/synapse. Please include the following data with your report: ----- -last_value: '%(last_value)', is_called: '%(is_called)', -max_stream_id: '%(max_stream_id)', -max_in_stream_positions: '%(max_in_stream_positions)' +last_value: '%(last_value)s', is_called: '%(is_called)s', +max_stream_id: '%(max_stream_id)s', +max_in_stream_positions: '%(max_in_stream_positions)s' ----- A temporary workaround to fix this error is to shut down Synapse (including diff --git a/tests/server.py b/tests/server.py index d17b2478e3..001d11e5e8 100644 --- a/tests/server.py +++ b/tests/server.py @@ -387,7 +387,7 @@ def make_request( shorthand: Whether to try and be helpful and prefix the given URL with the usual REST API path, if it doesn't contain it. federation_auth_origin: if set to not-None, we will add a fake - Authorization header pretenting to be the given server name. + Authorization header pretending to be the given server name. content_type: The content-type to use for the request. If not set then will default to application/json unless content_is_form is true. content_is_form: Whether the content is URL encoded form data. Adds the diff --git a/tests/storage/test_id_generators.py b/tests/storage/test_id_generators.py index 051c5de44d..cae00c3ba7 100644 --- a/tests/storage/test_id_generators.py +++ b/tests/storage/test_id_generators.py @@ -30,13 +30,14 @@ from synapse.storage.types import Cursor from synapse.storage.util.id_generators import MultiWriterIdGenerator from synapse.storage.util.sequence import ( + _INCONSISTENT_STREAM_ERROR, LocalSequenceGenerator, PostgresSequenceGenerator, SequenceGenerator, ) from synapse.util.clock import Clock -from tests.unittest import HomeserverTestCase +from tests.unittest import HomeserverTestCase, TestCase from tests.utils import USE_POSTGRES_FOR_TESTS @@ -789,3 +790,28 @@ def test_load_existing_stream(self) -> None: self.assertEqual(second_id_gen.get_current_token_for_writer("first"), 7) self.assertEqual(second_id_gen.get_current_token_for_writer("second"), 7) self.assertEqual(second_id_gen.get_persisted_upto_position(), 7) + + +class InconsistentStreamErrorFormatTest(TestCase): + """Test that _INCONSISTENT_STREAM_ERROR can be formatted without raising a + ValueError. + """ + + def test_format_with_all_parameters(self) -> None: + params = { + "seq": "events_sequence", + "stream_name": "events", + "last_value": 42, + "is_called": True, + "max_stream_id": 50, + "max_in_stream_positions": 55, + } + + result = _INCONSISTENT_STREAM_ERROR % params + + self.assertIn("events_sequence", result) + self.assertIn("events", result) + self.assertIn("42", result) + self.assertIn("True", result) + self.assertIn("50", result) + self.assertIn("55", result) diff --git a/tests/unittest.py b/tests/unittest.py index 79251cd76c..0220548d7b 100644 --- a/tests/unittest.py +++ b/tests/unittest.py @@ -604,7 +604,7 @@ def make_request( shorthand: Whether to try and be helpful and prefix the given URL with the usual REST API path, if it doesn't contain it. federation_auth_origin: if set to not-None, we will add a fake - Authorization header pretenting to be the given server name. + Authorization header pretending to be the given server name. content_type: The content-type to use for the request. If not set then will default to application/json unless content_is_form is true.