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

Fix handling of "off" in encryption_enabled_by_default_for_room_type#7822

Merged
babolivier merged 2 commits into
developfrom
babolivier/encryption_off
Jul 13, 2020
Merged

Fix handling of "off" in encryption_enabled_by_default_for_room_type#7822
babolivier merged 2 commits into
developfrom
babolivier/encryption_off

Conversation

@babolivier
Copy link
Copy Markdown
Contributor

Fixes #7821, introduced in #7639

Turns out PyYAML translates off into a False boolean if it's
unquoted (see https://stackoverflow.com/questions/36463531/pyyaml-automatically-converting-certain-keys-to-boolean-values),
which seems to be a liberal interpretation of this bit of the YAML spec: https://yaml.org/spec/1.1/current.html#id864510

An alternative fix would be to implement the solution mentioned in the
SO post linked above, but I'm aware it might break existing setups
(which might use these values in the configuration file) so it's
probably better just to add an extra check for this one. We should be
aware that this is a thing for the next times we do that though.

I didn't find any other occurrence of this bug elsewhere in the
codebase.

Fixes #7821, introduced in #7639

Turns out PyYAML translates `off` into a `False` boolean if it's
unquoted (see https://stackoverflow.com/questions/36463531/pyyaml-automatically-converting-certain-keys-to-boolean-values),
which seems to be a liberal interpretation of this bit of the YAML spec: https://yaml.org/spec/1.1/current.html#id864510

An alternative fix would be to implement the solution mentioned in the
SO post linked above, but I'm aware it might break existing setups
(which might use these values in the configuration file) so it's
probably better just to add an extra check for this one. We should be
aware that this is a thing for the next times we do that though.

I didn't find any other occurrence of this bug elsewhere in the
codebase.
Comment thread synapse/config/room.py Outdated
Copy link
Copy Markdown
Member

@clokep clokep left a comment

Choose a reason for hiding this comment

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

Makes sense. Did you check if we use the literal string "off" for any other settings?

@babolivier
Copy link
Copy Markdown
Contributor Author

Yes, that's what I meant by

I didn't find any other occurrence of this bug elsewhere in the
codebase.

@babolivier babolivier merged commit 504c8f3 into develop Jul 13, 2020
@babolivier babolivier deleted the babolivier/encryption_off branch July 13, 2020 16:14
@clokep
Copy link
Copy Markdown
Member

clokep commented Jul 13, 2020

Yes, that's what I meant by

I didn't find any other occurrence of this bug elsewhere in the
codebase.

I guess it helps if I read the whole description. 🤦 Thanks!

babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit '504c8f348':
  Fix handling of "off" in encryption_enabled_by_default_for_room_type (#7822)
  Update grafana dashboard
Comment thread synapse/config/room.py
Comment on lines +57 to +58
# PyYAML translates "off" into False if it's unquoted, so we also need to
# check for encryption_for_room_type being False.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be extra pedantic, it's part of YAML 1.1 and not present in YAML 1.2.2, or at least not mentioned in the spec: https://yaml.org/spec/1.2.2/#1032-tag-resolution

PyYAML implements YAML 1.1 I believe.

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.

ERROR: Invalid value for encryption_enabled_by_default_for_room_type

5 participants