Skip to content

Fix config profiles quickly get polluted with untouched settings#17158

Merged
seanbudd merged 6 commits into
nvaccess:masterfrom
LeonarddeR:fixFeatureFlagSave
Sep 17, 2024
Merged

Fix config profiles quickly get polluted with untouched settings#17158
seanbudd merged 6 commits into
nvaccess:masterfrom
LeonarddeR:fixFeatureFlagSave

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Sep 11, 2024

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixes #17157
Fixup of #14133
Partially reverts #15074

Summary of the issue:

When saving configuration profiles, unchanged values are yet saved to a profile.

Description of user facing changes

Configuration profiles should become less polluted after this change.

Description of development approach

Restored the behavior of #14133, mostly reverting #15074. There was namely a False assumption in #15074.
@seanbudd wrote:

This caused various issues including config values not being correctly converted to numbers from strings when validating.

In fact, the validation was not the problem here. Instead, when __getitem__ was called with checkValidity set to False, the unvalidated value was yet saved in the cache. Therefore subsequent calls of __getitem__ would always return the unvalidated cached value that would always be of the string type.

Testing strategy:

Known issues with pull request:

None known

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.

Summary by CodeRabbit

  • New Features

    • Improved handling of configuration settings to prevent redundant storage of identical values in the active configuration profile.
  • Bug Fixes

    • Resolved an issue that caused certain settings to be incorrectly saved, enhancing the integrity of the configuration management process.
  • Documentation

    • Updated user documentation to include notes on recent fixes related to configuration settings.

@LeonarddeR LeonarddeR changed the base branch from beta to master September 11, 2024 06:50
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@CyrilleB79 Would you be able to assist with testing to ensure we don't reintroduce anything from #14760 with this pr?

@LeonarddeR LeonarddeR marked this pull request as ready for review September 11, 2024 14:55
@LeonarddeR LeonarddeR requested a review from a team as a code owner September 11, 2024 14:55
@LeonarddeR LeonarddeR requested a review from seanbudd September 11, 2024 14:55
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 11, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The changes in this pull request focus on enhancing the logic for handling configuration settings in the application. Modifications were made to the __getitem__ and __setitem__ methods to improve value validation and update conditions. Additionally, a fix was implemented to prevent identical settings from being redundantly saved to the active configuration profile, addressing issues with configuration pollution.

Changes

Files Change Summary
source/config/init.py Modified __getitem__ to return unvalidated values directly and refined __setitem__ logic for updates.
user_docs/en/changes.md Added documentation regarding the fix for saving settings in the active configuration profile.

Assessment against linked issues

Objective Addressed Explanation
Prevent saving identical settings in active configuration (#[17157])

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai generate interesting stats about this repository and render them as a table.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
user_docs/en/changes.md (1)

Line range hint 1-1: TODO: Add tests

This comment indicates that tests are currently missing for this module. Adding tests is important to ensure the code functions correctly and to prevent regressions when making changes.

Do you need any help with writing tests for this code? I'd be happy to provide guidance on effective test cases to cover. Let me know if you'd like me to open a GitHub issue to track the task of adding tests.

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 20bdb39 and e702421.

Files selected for processing (2)
  • source/config/init.py (3 hunks)
  • user_docs/en/changes.md (1 hunks)
Additional context used
Path-based instructions (2)
source/config/__init__.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

user_docs/en/changes.md (3)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious. When providing code suggestions, particularly when requested, ensure GitHub's suggestion format is used, i.e.: suggestion <code changes>


Pattern **/*.md: Focus on grammar, spelling, and punctuation. Also consider readability and clarity of contents. Ensure that changes follow the style of one sentence per line, suggest changes if this is not met.


Pattern user_docs/en/changes.md: Ensure each change log entry references an issue or pull request number. Change log entries can also include a reference to a GitHub author. Examples of valid change log entries: * Item with sub-items (#123, @username): * sub-item * bar (#342) * Item with. Multiple lines. (#143)

Additional comments not posted (2)
source/config/__init__.py (2)

1148-1148: LGTM!

The change to directly return val when checkValidity is False is approved. This emphasizes that unvalidated values should not be cached, potentially improving the integrity of the cached data.


1293-1296: LGTM!

The changes to the conditional checks for updating values are approved. They simplify the logic and enhance clarity regarding when updates should occur.

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it possible to create a unit test which covers this case in tests/unit/test_config.py?

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@seanbudd I just created unit tests and checked that the tests fail without the patch in this pr.

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perfect, thanks @LeonarddeR

Comment thread tests/unit/test_config.py Outdated
@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Sep 17, 2024
@seanbudd seanbudd merged commit ca26d32 into nvaccess:master Sep 17, 2024
@github-actions github-actions Bot added this to the 2025.1 milestone Sep 17, 2024
@LeonarddeR LeonarddeR deleted the fixFeatureFlagSave branch August 23, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config profiles quickly get polluted with untouched settings

2 participants