This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix a typing issue in the federation client code found with mypy #7089
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a bug in the federation API which could cause occasional "Failed to get PDU" errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,7 +409,7 @@ async def on_invite_request( | |
pdu = event_from_pdu_json(content, room_version) | ||
origin_host, _ = parse_server_name(origin) | ||
await self.check_server_matches_acl(origin_host, pdu.room_id) | ||
pdu = await self._check_sigs_and_hash(room_version.identifier, pdu) | ||
pdu = await self._check_sigs_and_hash(room_version, pdu) | ||
ret_pdu = await self.handler.on_invite_request(origin, pdu, room_version) | ||
time_now = self._clock.time_msec() | ||
return {"event": ret_pdu.get_pdu_json(time_now)} | ||
|
@@ -425,7 +425,7 @@ async def on_send_join_request(self, origin, content, room_id): | |
|
||
logger.debug("on_send_join_request: pdu sigs: %s", pdu.signatures) | ||
|
||
pdu = await self._check_sigs_and_hash(room_version.identifier, pdu) | ||
pdu = await self._check_sigs_and_hash(room_version, pdu) | ||
|
||
res_pdus = await self.handler.on_send_join_request(origin, pdu) | ||
time_now = self._clock.time_msec() | ||
|
@@ -455,7 +455,7 @@ async def on_send_leave_request(self, origin, content, room_id): | |
|
||
logger.debug("on_send_leave_request: pdu sigs: %s", pdu.signatures) | ||
|
||
pdu = await self._check_sigs_and_hash(room_version.identifier, pdu) | ||
pdu = await self._check_sigs_and_hash(room_version, pdu) | ||
|
||
await self.handler.on_send_leave_request(origin, pdu) | ||
return {} | ||
|
@@ -611,7 +611,7 @@ async def _handle_received_pdu(self, origin, pdu): | |
logger.info("Accepting join PDU %s from %s", pdu.event_id, origin) | ||
|
||
# We've already checked that we know the room version by this point | ||
room_version = await self.store.get_room_version_id(pdu.room_id) | ||
room_version = await self.store.get_room_version(pdu.room_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One difference here is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't really matter, because |
||
|
||
# Check signature. | ||
try: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not saying that we should undo it (it's certainly much cleaner now), but for the record: this seems to go beyond what is needed to fix the issue here. afaict only the calls to
_check_sigs_and_hash_and_fetch
needed changing;_check_sigs_and_hash
,_check_sigs_and_hashes
and_check_sigs_on_pdus
were ok.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does go a bit beyond the minimum, but it seemed clearer / more efficient to not switch back and forth between
RoomVersion
and astr
repeatedly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, fair.