Skip to content

Fix up config upgrade steps from schema version 14 to 15#17642

Merged
SaschaCowley merged 3 commits into
masterfrom
fixupTypingEcho
Jan 24, 2025
Merged

Fix up config upgrade steps from schema version 14 to 15#17642
SaschaCowley merged 3 commits into
masterfrom
fixupTypingEcho

Conversation

@SaschaCowley

@SaschaCowley SaschaCowley commented Jan 23, 2025

Copy link
Copy Markdown
Member

Link to issue number:

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.

These config upgrade steps also upgrade a value of True to a value of TypingEcho.EDIT_CONTROLS, even though the behaviour of True is the same as that of TypingEcho.ALWAYS.

Description of user facing changes

The configuration upgrade should not corrupt the user's config.

If the user has changed the behaviour of either of these options, the behaviour will not change for them.

Description of development approach

Instead of just returning when we get a ValueError in upgradeConfigFrom_14_to_15, delete the offending config entry.

Change the mapping for True to TypingEcho.ALWAYS when converting from an existing boolean to a new integer.

Testing strategy:

Tested by creating valid and invalid config strings, instantiating ConfigObjs 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.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@coderabbitai summary

@SaschaCowley SaschaCowley added the blocked/needs-info The issue can not be progressed until more information is provided. label Jan 23, 2025
@SaschaCowley

Copy link
Copy Markdown
Member Author

Added blocked/needs-info until we know more what's going on in #17637.

@SaschaCowley SaschaCowley marked this pull request as ready for review January 23, 2025 06:31
@SaschaCowley SaschaCowley requested a review from a team as a code owner January 23, 2025 06:31
@SaschaCowley SaschaCowley requested a review from seanbudd January 23, 2025 06:31
@SaschaCowley

Copy link
Copy Markdown
Member Author

@cary-rowen Pinging you as this is based on your work :)

@cary-rowen

Copy link
Copy Markdown
Contributor

Thanks @SaschaCowley I haven't figured out the real cause of #17637. But sorry about that!

Comment thread source/config/profileUpgradeSteps.py Outdated

@CyrilleB79 CyrilleB79 left a comment

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.

Here is my feedback.

In addition, I notice that upgradeConfigFrom_12_to_13 uses the same pattern. It has probably not caused any issue since it has already made its way in a stable release.

Since the new upgrade function had probably been copied from upgradeConfigFrom_12_to_13, would it be worth to also modify it so that we do not copy this pattern anymore?

Comment thread source/config/profileUpgradeSteps.py Outdated
Comment thread source/config/profileUpgradeSteps.py Outdated
@SaschaCowley

Copy link
Copy Markdown
Member Author

@CyrilleB79, upgradeConfigFrom_12_to_13 does not use the same pattern. This class of issue relies on the config path remaining the same, but the type changing. If a setting is being created at a new config path from one at an old config path, and the value at the old config path is not recognised by the upgrade step , this can be ignored, as the old path will not be in the config schema, so its type will not matter when NVDA validates the config.

@SaschaCowley SaschaCowley merged commit 8ec1116 into master Jan 24, 2025
@SaschaCowley SaschaCowley deleted the fixupTypingEcho branch January 24, 2025 03:16
@github-actions github-actions Bot added this to the 2025.1 milestone Jan 24, 2025
LeonarddeR pushed a commit to LeonarddeR/nvda that referenced this pull request Feb 4, 2025
)

Fixes nvaccess#17637
Follow-up to nvaccess#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked/needs-info The issue can not be progressed until more information is provided.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config upgrade/speak typed characters and words: keys "speakTypedCharacters" and "speakTypedWords" are of the wrong type

4 participants