element-hq / element-hq/synapse

simple_* methods handle `None` incorrectly for key values

Open
#14,157 0 comments 0 reactions 0 assignees View on GitHub
A-Database O-Uncommon S-Minor T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

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

---

Generally the `simple_*` methods do not handle `None` properly when used as a key-value (the exact arguments differ by method). See #14138 for real fallout from this.

`simple_upsert_emulated_txn` has special handling for `null` which should likely be abstracted:

https://github.com/matrix-org/synapse/blob/b4ec4f5e71a87d5bdc840a4220dfd9a34c54c847/synapse/storage/database.py#L1304-L1310

This is mostly a footgun that we could avoid by either:

1. Raising an exception (or asserting) when a key-value is `None`.
2. Automatically handling `None` and turning it into `IS NONE` (which is what `simple_upsert_emulated_txn` does).

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.