We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 25cd3d2 commit da8be8dCopy full SHA for da8be8d
2 files changed
changelog.d/7188.misc
@@ -0,0 +1 @@
1
+Fix consistency of HTTP status codes reported in log lines.
synapse/api/errors.py
@@ -86,7 +86,14 @@ class CodeMessageException(RuntimeError):
86
87
def __init__(self, code, msg):
88
super(CodeMessageException, self).__init__("%d: %s" % (code, msg))
89
- self.code = code
+
90
+ # Some calls to this method pass instances of http.HTTPStatus for `code`.
91
+ # While HTTPStatus is a subclass of int, it has magic __str__ methods
92
+ # which emit `HTTPStatus.FORBIDDEN` when converted to a str, instead of `403`.
93
+ # This causes inconsistency in our log lines.
94
+ #
95
+ # To eliminate this behaviour, we convert them to their integer equivalents here.
96
+ self.code = int(code)
97
self.msg = msg
98
99
0 commit comments