Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix to-device messages not being sent to MSC3202-enabled appservices #13235

Merged
merged 4 commits into from
Jul 11, 2022

Conversation

turt2live
Copy link
Member

@turt2live turt2live commented Jul 9, 2022

The field name was simply incorrect, leading to errors.

Fixes turt2live/matrix-bot-sdk#208 (mostly)

Example error:

element-dev-stack-eledev-synapse-1      | 2022-07-09 01:52:01,578 - synapse.metrics.background_process_metrics - 242 - ERROR - as-sender-encrypted_appservices-4 - Background process 'as-sender-encrypted_appservices' threw an exception
element-dev-stack-eledev-synapse-1      | Traceback (most recent call last):
element-dev-stack-eledev-synapse-1      |   File "/usr/local/lib/python3.9/site-packages/twisted/internet/defer.py", line 1660, in _inlineCallbacks
element-dev-stack-eledev-synapse-1      |     result = current_context.run(gen.send, result)
element-dev-stack-eledev-synapse-1      | StopIteration: ({('@crypto_bot_user:localhost', 'URSRMAKHSN'): [{'content': {'algorithm': 'm.olm.v1.curve25519-aes-sha2', 'sender_key': 'GBc4Vu8RoVOy14212/sMAxA6oJ+ii6xsTdc9oaoY6j8', 'ciphertext': {'LU38crr35sqw4Sbm9gy3BA6dCfaxZWV4KomAEnJgmUU': {'type': 0, 'body': 'redacted'}}}, 'type': 'm.room.encrypted', 'sender': '@travis:localhost'}]}, 5379)
element-dev-stack-eledev-synapse-1      | 
element-dev-stack-eledev-synapse-1      | During handling of the above exception, another exception occurred:
element-dev-stack-eledev-synapse-1      | 
element-dev-stack-eledev-synapse-1      | Traceback (most recent call last):
element-dev-stack-eledev-synapse-1      |   File "/usr/local/lib/python3.9/site-packages/synapse/metrics/background_process_metrics.py", line 240, in run
element-dev-stack-eledev-synapse-1      |     return await func(*args, **kwargs)
element-dev-stack-eledev-synapse-1      |   File "/usr/local/lib/python3.9/site-packages/synapse/appservice/scheduler.py", line 274, in _send_request
element-dev-stack-eledev-synapse-1      |     ) = await self._compute_msc3202_otk_counts_and_fallback_keys(
element-dev-stack-eledev-synapse-1      |   File "/usr/local/lib/python3.9/site-packages/synapse/appservice/scheduler.py", line 333, in _compute_msc3202_otk_counts_and_fallback_keys
element-dev-stack-eledev-synapse-1      |     users.update(device_message["user_id"] for device_message in to_device_messages)
element-dev-stack-eledev-synapse-1      |   File "/usr/local/lib/python3.9/site-packages/synapse/appservice/scheduler.py", line 333, in <genexpr>
element-dev-stack-eledev-synapse-1      |     users.update(device_message["user_id"] for device_message in to_device_messages)
element-dev-stack-eledev-synapse-1      | KeyError: 'user_id'

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Pull request includes a sign off
  • Code style is correct
    (run the linters)

@turt2live turt2live marked this pull request as ready for review July 9, 2022 02:11
@turt2live turt2live requested a review from a team as a code owner July 9, 2022 02:11
@turt2live
Copy link
Member Author

turt2live commented Jul 9, 2022

hmm, as of writing github is missing a whole 2 commits from this PR for some reason. They're on the branch: develop...travis/fix-enc-appservices

Edit: and of course they magically surfaced...

@squahtx
Copy link
Contributor

squahtx commented Jul 11, 2022

The bug has existed since the implementation of MSC3202 in #11617.
The to_user_id field name comes from MSC2409, implemented in #11215.

Copy link
Contributor

@squahtx squahtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@squahtx squahtx merged commit d736d5c into develop Jul 11, 2022
@squahtx squahtx deleted the travis/fix-enc-appservices branch July 11, 2022 16:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encrypted appservices can't decrypt event: decryption failed because the room key is missing
2 participants