Skip to content

Commit 8df5163

Browse files
chore: fix the inconsistent stream error log message (#238)
- fix the inconsistent stream error log message to contain the proper information instead of raising value error - fix typo
2 parents e9af5a2 + 47df28f commit 8df5163

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

synapse/storage/util/sequence.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
https://github.com/matrix-org/synapse. Please include the following data with
4545
your report:
4646
-----
47-
last_value: '%(last_value)', is_called: '%(is_called)',
48-
max_stream_id: '%(max_stream_id)',
49-
max_in_stream_positions: '%(max_in_stream_positions)'
47+
last_value: '%(last_value)s', is_called: '%(is_called)s',
48+
max_stream_id: '%(max_stream_id)s',
49+
max_in_stream_positions: '%(max_in_stream_positions)s'
5050
-----
5151
5252
A temporary workaround to fix this error is to shut down Synapse (including

tests/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def make_request(
387387
shorthand: Whether to try and be helpful and prefix the given URL
388388
with the usual REST API path, if it doesn't contain it.
389389
federation_auth_origin: if set to not-None, we will add a fake
390-
Authorization header pretenting to be the given server name.
390+
Authorization header pretending to be the given server name.
391391
content_type: The content-type to use for the request. If not set then will default to
392392
application/json unless content_is_form is true.
393393
content_is_form: Whether the content is URL encoded form data. Adds the

tests/storage/test_id_generators.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@
3030
from synapse.storage.types import Cursor
3131
from synapse.storage.util.id_generators import MultiWriterIdGenerator
3232
from synapse.storage.util.sequence import (
33+
_INCONSISTENT_STREAM_ERROR,
3334
LocalSequenceGenerator,
3435
PostgresSequenceGenerator,
3536
SequenceGenerator,
3637
)
3738
from synapse.util.clock import Clock
3839

39-
from tests.unittest import HomeserverTestCase
40+
from tests.unittest import HomeserverTestCase, TestCase
4041
from tests.utils import USE_POSTGRES_FOR_TESTS
4142

4243

@@ -789,3 +790,28 @@ def test_load_existing_stream(self) -> None:
789790
self.assertEqual(second_id_gen.get_current_token_for_writer("first"), 7)
790791
self.assertEqual(second_id_gen.get_current_token_for_writer("second"), 7)
791792
self.assertEqual(second_id_gen.get_persisted_upto_position(), 7)
793+
794+
795+
class InconsistentStreamErrorFormatTest(TestCase):
796+
"""Test that _INCONSISTENT_STREAM_ERROR can be formatted without raising a
797+
ValueError.
798+
"""
799+
800+
def test_format_with_all_parameters(self) -> None:
801+
params = {
802+
"seq": "events_sequence",
803+
"stream_name": "events",
804+
"last_value": 42,
805+
"is_called": True,
806+
"max_stream_id": 50,
807+
"max_in_stream_positions": 55,
808+
}
809+
810+
result = _INCONSISTENT_STREAM_ERROR % params
811+
812+
self.assertIn("events_sequence", result)
813+
self.assertIn("events", result)
814+
self.assertIn("42", result)
815+
self.assertIn("True", result)
816+
self.assertIn("50", result)
817+
self.assertIn("55", result)

tests/unittest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ def make_request(
604604
shorthand: Whether to try and be helpful and prefix the given URL
605605
with the usual REST API path, if it doesn't contain it.
606606
federation_auth_origin: if set to not-None, we will add a fake
607-
Authorization header pretenting to be the given server name.
607+
Authorization header pretending to be the given server name.
608608
609609
content_type: The content-type to use for the request. If not set then will default to
610610
application/json unless content_is_form is true.

0 commit comments

Comments
 (0)