Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression: make BASE_ONLY_SECTIONS no longer a frozen set #16685

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

seanbudd
Copy link
Member

@seanbudd seanbudd commented Jun 13, 2024

Link to issue number:

Fixes #16684

Summary of the issue:

In #16636 / d7facd1, config.ConfigManager.BASE_ONLY_SECTIONS underwent a mutation from a set to a frozenset.
Thhis modification hinders extensions from easily expanding this set.

There are perfectly legit scenarios where an extension’s settings should not be overridden by profiles. Take webAccess, for instance: accessolutions/WebAccessForNVDA@4251aae/addon/globalPlugins/webAccess/config.py

Description of user facing changes

None

Description of development approach

Undo change in #16636

Testing strategy:

Known issues with pull request:

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

  • Documentation

    • Enhanced documentation for the ConfigManager class to clarify the purpose of BASE_ONLY_SECTIONS.
  • Refactor

    • Updated BASE_ONLY_SECTIONS from a frozenset to a dictionary for better structure and readability.

@seanbudd seanbudd requested a review from a team as a code owner June 13, 2024 05:10
@seanbudd seanbudd requested a review from SaschaCowley June 13, 2024 05:10
Copy link
Contributor

coderabbitai bot commented Jun 13, 2024

Walkthrough

The ConfigManager class in source/config/__init__.py updated its BASE_ONLY_SECTIONS from a frozenset to a dictionary, enabling easier expansion by add-ons. Additional documentation explaining its intention is also included.

Changes

File Change Summary
source/config/__init__.py Converted BASE_ONLY_SECTIONS from frozenset to a dictionary and added documentation to clarify its purpose.

Assessment against linked issues

Objective Addressed Explanation
Enable extensions to easily expand BASE_ONLY_SECTIONS (Issue #16684)
Address the regression caused by changing BASE_ONLY_SECTIONS from a set to a frozenset (Issue #16684)

Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ad9ed73 and 1772930.

Files selected for processing (1)
  • source/config/init.py (1 hunks)
Additional context used
Path-based instructions (1)
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.


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

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

507-518: Ensure that all references and manipulations of BASE_ONLY_SECTIONS throughout the ConfigManager class and related functions are consistent with its new data type as a modifiable set. This includes checking how it interacts with profile management and configuration validation.

Verification successful

The references to BASE_ONLY_SECTIONS in the source/config/__init__.py file appear to be consistent with its usage as a set. Here are the relevant lines:

  • Line where BASE_ONLY_SECTIONS is defined as a set.
  • Loop iterating over self.BASE_ONLY_SECTIONS.
  • Conditional check to see if a key is in self.BASE_ONLY_SECTIONS.

These usages are consistent with BASE_ONLY_SECTIONS being a set and do not indicate any issues.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Search for all references to `BASE_ONLY_SECTIONS` to ensure consistent usage.

# Test: Search for the variable usage. Expect: Consistent usage as a set.
rg --type python $'BASE_ONLY_SECTIONS'

Length of output: 68



Script:

#!/bin/bash
# Description: Search for all references to `BASE_ONLY_SECTIONS` to ensure consistent usage.

# Test: Search for the variable usage. Expect: Consistent usage as a set.
rg 'BASE_ONLY_SECTIONS'

Length of output: 202


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>.
    • 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 show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@seanbudd seanbudd added this to the 2024.3 milestone Jun 13, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
source/config/__init__.py (1)

507-518: Consider implementing additional validation or restrictions on which extensions can modify BASE_ONLY_SECTIONS, to mitigate potential security risks associated with unauthorized or malicious modifications.

source/config/__init__.py Show resolved Hide resolved
@seanbudd seanbudd requested a review from gerald-hartig June 16, 2024 23:43
@seanbudd seanbudd merged commit 9829b3b into master Jun 17, 2024
3 checks passed
@seanbudd seanbudd deleted the fix-16684 branch June 17, 2024 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: add-ons can no longer easily expand BASE_ONLY_SECTIONS Due to frozenset Change
2 participants