element-hq / element-hq/synapse

Remove backwards-compatibility code for access tokens without an associated device

Open
#11,829 0 comments 0 reactions 0 assignees View on GitHub
T-Task
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#11829](https://github.com/matrix-org/synapse/issues/11829).

---

I ran into this while implementing #11215.

Before https://github.com/matrix-org/synapse/pull/949, it was possible to have access tokens that were not associated with a device. This has now been deprecated for 5 years.

This possibility has now crept across the codebase, as we've marked `device_id` as `Optional` in many places, including:

https://github.com/matrix-org/synapse/blob/d4e6f358b64b340a670e4f7496a530c11a715920/synapse/handlers/sync.py#L87-L93

This makes little sense, as you're expected to have a device if you're calling `/sync`. Much of the `/sync` handling code assumes you have a device, and would logically fail if the user didn't:

https://github.com/matrix-org/synapse/blob/3e0536cd2afb5a640619bd872fc27b068ec3eb9b/synapse/storage/databases/main/deviceinbox.py#L199-L201

Passing `device_id=None` to this function always results in zero to-device messages being returned.

Is there anything holding us back (old access tokens?) from marking device IDs as `str`, not `Optional[str]`?

Edit: There are currently `64` entries in the `access_tokens` table on matrix.org that do not have an associated device ID. They are all either abuse, or go neb...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.