Skip to content

Commit

Permalink
Require that "m.server" maps to string
Browse files Browse the repository at this point in the history
This accounts for [this Sentry error](https://sentry.matrix.org/sentry/sydent/issues/236101/).

I haven't written a test for this because a) I'm hungry and b) this
is shared code with Synapse which ought to be pulled out to a common
library and tested there; c.f.
matrix-org/matrix-python-common#3.
  • Loading branch information
David Robertson committed Nov 24, 2021
1 parent cf27fce commit fae60d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/473.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug where federation requests would fail early if a `.well-known/matrix/server` response contains an invalid type for `m.server`. Instead, try finding an SRV record, as mandated by [the spec](https://spec.matrix.org/v1.1/server-server-api/#resolving-server-names).
2 changes: 2 additions & 0 deletions sydent/http/matrixfederationagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ async def _do_get_well_known(
raise Exception("not a dict")
if "m.server" not in parsed_body:
raise Exception("Missing key 'm.server'")
if not isinstance(parsed_body["m.server"], str):
raise TypeError("m.server must be a string")
except Exception as e:
logger.info("Error fetching %s: %s", uri_str, e)

Expand Down

0 comments on commit fae60d9

Please sign in to comment.