Skip to content

Commit

Permalink
Fix up config upgrade steps from schema version 14 to 15 (#17642)
Browse files Browse the repository at this point in the history
Fixes #17637
Follow-up to #17505

Summary of the issue:
The config upgrade steps for moving from version 14 to 15 of the config schema may leave the user's config in an invalid state if either of `["keyboard"]["speakTypedCharacters"]` or `["keyboard"]["speakTypedWords"]` is not a boolean.
This is because the upgrade steps, as implemented, take no action if those values are not bools.
For most upgrade steps, this approach is perfectly valid.
However, version 15 of the schema expects these values to be integers, so validation of the upgraded config will fail.

Description of user facing changes
The configuration upgrade should not corrupt the user's config.

Description of development approach
Instead of just `return`ing when we get a `ValueError` in `upgradeConfigFrom_14_to_15`, delete the offending config entry.


Testing strategy:
Tested by creating valid and invalid config strings, instantiating `ConfigObj`s with them, and feeding those to `upgradeConfigFrom_14_to_15`.

Known issues with pull request:
A user may lose their setting for "Speak typed characters" or "Speak typed words", if configobj doesn't recognise it as a boolean.
Theoretically this shouldn't be possible, as the config wouldn't have validated under any of the prior schema versions.
Nevertheless this seems to have happened, and it is better to lose (at most) 2 settings than all settings.
  • Loading branch information
SaschaCowley authored Jan 24, 2025
1 parent bf3ba01 commit 8ec1116
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/config/profileUpgradeSteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ def _convertTypingEcho(profile: ConfigObj, key: str) -> None:
log.debug(f"'{key}' not present in config, no action taken.")
return
except ValueError:
log.error(f"'{key}' is not a boolean, no action taken.")
log.error(f"'{key}' is not a boolean, got {profile['keyboard'][key]!r}. Deleting.")
del profile["keyboard"][key]
return
else:
newValue = TypingEcho.EDIT_CONTROLS.value if oldValue else TypingEcho.OFF.value
Expand Down

0 comments on commit 8ec1116

Please sign in to comment.