Skip to content

fix: compare configuration skip keys case-insensitively - #2689

Merged
IsmaelMartinez merged 5 commits into
The-PR-Agent:mainfrom
dwin-gharibi:fix/skip-keys-case-insensitive
Aug 21, 2026
Merged

IsmaelMartinez merged 5 commits into
The-PR-Agent:mainfrom
dwin-gharibi:fix/skip-keys-case-insensitive

Conversation

@dwin-gharibi

Copy link
Copy Markdown
Contributor

Closes #2688.

Description

analytics_folder and app_name are published into the PR comment despite being in the default skip list.

Root cause

show_relevant_configurations compared with if key in skip_keys (pr_agent/algo/utils.py:1287,1293) while Dynaconf yields section keys lower-cased, so the upper-case entries in the default list could never match. pr_agent/tools/pr_config.py:65 already does this correctly via skip_keys_lower, so the two implementations had diverged.

The fix

Lower-case both sides, mirroring the existing approach in pr_config.py.

Behaviour change

Before app_name: my-app and analytics_folder: /srv/secret-analytics rendered into the PR comment
After both omitted

Verified the rendered block no longer contains either key.

Files changed

pr_agent/algo/utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Testing

  • pytest tests/unittest — 1748 passed, 1 skipped, 1 xfailed (unchanged from main)
  • CI pipeline reproduced locally exactly as .github/workflows/build-and-test.yaml runs it:
    docker build -f docker/Dockerfile --target test .
    docker run --rm <image> pytest -v tests/unittest
    
    → 1748 passed, 1 skipped, 1 xfailed on python:3.12.13-slim
  • Targeted regression check for this defect: reproduced on main, no longer reproducible on this branch
  • ruff — no new findings vs main; isort — clean

Risk / compatibility

Only hides keys the default list already intended to hide.

Checklist

  • Focused on a single fix
  • Existing tests pass
  • No new dependencies
  • No user-facing configuration changes
  • Reviewed by a maintainer

Copilot AI lite review requested due to automatic review settings August 17, 2026 16:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Fix config skip-key filtering to be case-insensitive

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Fix skip-key filtering so config keys are compared case-insensitively
• Prevent app_name/analytics_folder from leaking into rendered PR comments
• Align utils.show_relevant_configurations() behavior with existing pr_config logic
Diagram

graph TD
  A["PR tools"] --> B["show_relevant_configurations()"] --> D["Case-insensitive\nskip filter"] --> E["PR comment\nmarkdown"]
  B --> C[("Dynaconf settings")]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract shared skip-key helper
  • ➕ Eliminates duplicated skip-key logic between utils.py and pr_config.py
  • ➕ Reduces risk of future divergence/regressions
  • ➖ Small refactor overhead for a narrow bug fix
  • ➖ May require updating imports and test touchpoints
2. Store skip keys normalized (lowercase) at definition time
  • ➕ Avoids repeated .lower() calls during iteration
  • ➕ Makes intended case-insensitive behavior explicit
  • ➖ Still leaves duplicated lists in multiple modules unless combined with a shared helper
  • ➖ Requires ensuring all contributors follow the convention for future additions

Recommendation: Current fix (lower-case both sides) is the right minimal change for this bug and mirrors existing pr_config.py behavior. If further changes are planned in this area, consider extracting a shared helper (or shared constant) to prevent the two skip-key implementations from drifting again.

Files changed (1) +3 / -2

Bug fix (1) +3 / -2
utils.pyMake skip-key filtering case-insensitive in config rendering +3/-2

Make skip-key filtering case-insensitive in config rendering

• Adds a lower-cased copy of the skip key list and compares configuration keys via 'key.lower()' during rendering. This prevents intended-to-be-hidden keys from appearing when Dynaconf provides lower-cased keys.

pr_agent/algo/utils.py

@qodo-code-review

qodo-code-review Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Handle non-string skip keys ✓ Resolved 🐞 Bug ☼ Reliability ⭐ New
Description
A numeric entry in config.skip_keys (for example, skip_keys = [123]) now makes
show_relevant_configurations() raise AttributeError while constructing skip_keys_lower,
preventing tools that render this block from publishing their result. Previously such an entry was
harmless to the membership checks because it was never dereferenced.
Code

pr_agent/algo/utils.py[1300]

+    skip_keys_lower = [key.lower() for key in skip_keys]
Relevance

●●● Strong

Recent accepted precedent validates configured list entries to prevent runtime failures; this is a
direct reliability fix in the same configuration pattern.

PR-#2503

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new list comprehension invokes .lower() on every default and configured skip-key item, while
configured values are appended without type validation. The configuration loader accepts TOML
settings files, and the shipped default only establishes the expected shape rather than enforcing it
for overrides.

pr_agent/algo/utils.py[1297-1300]
pr_agent/settings/configuration.toml[21-28]
pr_agent/config_loader.py[17-43]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`show_relevant_configurations()` lowercases every configured `config.skip_keys` item without checking its type. TOML configuration can supply a non-string list item, which makes comment rendering fail with `AttributeError`.

## Issue Context
The setting is extended directly into the default list without validation; default values happen to be strings, but repository/operator configuration is not constrained here.

## Fix Focus Areas
- pr_agent/algo/utils.py[1297-1300]
- pr_agent/algo/utils.py[1307-1313]
- tests/unittest/test_show_relevant_configurations.py[35-41]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Test leaves settings mutated ✓ Resolved 🐞 Bug ☼ Reliability
Description
The fixture restores every saved value with settings.set, so an originally absent key such as
config.analytics_folder, which is snapshotted as None, remains as a real None entry instead of
being removed. Because the test mutates the process-wide Dynaconf singleton, this newly created key
contaminates configuration state observed by subsequent tests.
Code

tests/unittest/test_show_relevant_configurations.py[R17-18]

+    for key, value in saved.items():
+        settings.set(f"config.{key}", value)
Relevance

●●● Strong

Recent accepted precedent fixes global Dynaconf test-state leakage through explicit restoration.

PR-#2406
PR-#2464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test obtains the global settings object, snapshots missing values using a None default,
creates the dotted key, and then unconditionally restores it with settings.set. The repository's
dedicated settings test helper explicitly documents that rewriting absent dotted keys as None
leaks state in the shared singleton, and instead uses a sentinel plus explicit removal;
get_settings(use_context=False) falls back to that global singleton.

tests/unittest/test_show_relevant_configurations.py[14-18]
tests/unittest/test_show_relevant_configurations.py[26-28]
tests/unittest/_settings_helpers.py[3-11]
pr_agent/config_loader.py[47-60]
tests/unittest/test_show_relevant_configurations.py[12-18]
tests/unittest/test_show_relevant_configurations.py[21-28]
pr_agent/config_loader.py[17-18]
tests/unittest/_settings_helpers.py[1-11]
tests/unittest/_settings_helpers.py[55-62]
PR-#2406

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Restore Dynaconf configuration keys that were absent before the test by removing them rather than setting them to `None`, preventing global configuration state from leaking across tests.

## Issue Context
`get_settings(use_context=False)` returns the process-wide Dynaconf singleton. `analytics_folder` is not a default configuration key, so the test snapshots it as `None`, creates the dotted key, and currently leaves it behind as a present key with a `None` value during teardown. Use the repository's sentinel-based settings snapshot/restore helpers, which remove dotted keys that were originally absent, or implement equivalent absent-key tracking and cleanup.

## Fix Focus Areas
- tests/unittest/test_show_relevant_configurations.py[12-18]
- tests/unittest/test_show_relevant_configurations.py[26-28]
- tests/unittest/_settings_helpers.py[21-24]
- tests/unittest/_settings_helpers.py[55-62]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

3. Test docstring lacks imperative phrasing ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The new docstring begins with the descriptive phrase The default skip list spells rather than an
imperative verb. Rewrite its opening to directly instruct or describe behavior imperatively, such as
Verify that default skip-list entries....
Code

tests/unittest/test_show_relevant_configurations.py[23]

+    """The default skip list spells some entries in upper case (ANALYTICS_FOLDER,
Relevance

● Weak

Recent identical imperative-docstring style suggestion was rejected.

PR-#2661

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 2694688 requires new docstrings to begin with imperative phrasing, while the added test
docstring starts with the descriptive third-person statement The default skip list spells.

Rule 2694688: Docstrings and comments must use imperative phrasing
tests/unittest/test_show_relevant_configurations.py[23-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Rewrite the test docstring so its first sentence begins with an imperative verb rather than the descriptive phrase `The default skip list spells`.

## Issue Context
PR Compliance ID 2694688 requires newly added or modified docstrings to use imperative phrasing. Preserve the explanation of the case-insensitive skip-key regression.

## Fix Focus Areas
- tests/unittest/test_show_relevant_configurations.py[23-25]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Grey Divider

Context sources
✅ Compliance rules (platform): 34 rules
Review mode: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 13/18, lines 173/200; both must reach the floor). Router rationale: The latest push changes several independent runtime paths—patch parsing/range handling, configuration filtering, and webhook authentication—with security-sensitive behavior and multiple easy-to-miss edge cases.

Grey Divider

Tip of the day
💡 Did you know, you can tweak Display preferences with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 92f5961

Results up to commit c810105 🧠 Deep


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 📜 Skill insights (0)


Remediation recommended
1. Test leaves settings mutated ✓ Resolved 🐞 Bug ☼ Reliability
Description
The fixture restores every saved value with settings.set, so an originally absent key such as
config.analytics_folder, which is snapshotted as None, remains as a real None entry instead of
being removed. Because the test mutates the process-wide Dynaconf singleton, this newly created key
contaminates configuration state observed by subsequent tests.
Code

tests/unittest/test_show_relevant_configurations.py[R17-18]

+    for key, value in saved.items():
+        settings.set(f"config.{key}", value)
Relevance

●●● Strong

Recent accepted precedent fixes global Dynaconf test-state leakage through explicit restoration.

PR-#2406
PR-#2464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test obtains the global settings object, snapshots missing values using a None default,
creates the dotted key, and then unconditionally restores it with settings.set. The repository's
dedicated settings test helper explicitly documents that rewriting absent dotted keys as None
leaks state in the shared singleton, and instead uses a sentinel plus explicit removal;
get_settings(use_context=False) falls back to that global singleton.

tests/unittest/test_show_relevant_configurations.py[14-18]
tests/unittest/test_show_relevant_configurations.py[26-28]
tests/unittest/_settings_helpers.py[3-11]
pr_agent/config_loader.py[47-60]
tests/unittest/test_show_relevant_configurations.py[12-18]
tests/unittest/test_show_relevant_configurations.py[21-28]
pr_agent/config_loader.py[17-18]
tests/unittest/_settings_helpers.py[1-11]
tests/unittest/_settings_helpers.py[55-62]
PR-#2406

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Restore Dynaconf configuration keys that were absent before the test by removing them rather than setting them to `None`, preventing global configuration state from leaking across tests.

## Issue Context
`get_settings(use_context=False)` returns the process-wide Dynaconf singleton. `analytics_folder` is not a default configuration key, so the test snapshots it as `None`, creates the dotted key, and currently leaves it behind as a present key with a `None` value during teardown. Use the repository's sentinel-based settings snapshot/restore helpers, which remove dotted keys that were originally absent, or implement equivalent absent-key tracking and cleanup.

## Fix Focus Areas
- tests/unittest/test_show_relevant_configurations.py[12-18]
- tests/unittest/test_show_relevant_configurations.py[26-28]
- tests/unittest/_settings_helpers.py[21-24]
- tests/unittest/_settings_helpers.py[55-62]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
2. Test docstring lacks imperative phrasing ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The new docstring begins with the descriptive phrase The default skip list spells rather than an
imperative verb. Rewrite its opening to directly instruct or describe behavior imperatively, such as
Verify that default skip-list entries....
Code

tests/unittest/test_show_relevant_configurations.py[23]

+    """The default skip list spells some entries in upper case (ANALYTICS_FOLDER,
Relevance

● Weak

Recent identical imperative-docstring style suggestion was rejected.

PR-#2661

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 2694688 requires new docstrings to begin with imperative phrasing, while the added test
docstring starts with the descriptive third-person statement The default skip list spells.

Rule 2694688: Docstrings and comments must use imperative phrasing
tests/unittest/test_show_relevant_configurations.py[23-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Rewrite the test docstring so its first sentence begins with an imperative verb rather than the descriptive phrase `The default skip list spells`.

## Issue Context
PR Compliance ID 2694688 requires newly added or modified docstrings to use imperative phrasing. Preserve the explanation of the case-insensitive skip-key regression.

## Fix Focus Areas
- tests/unittest/test_show_relevant_configurations.py[23-25]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@dwin-gharibi

Copy link
Copy Markdown
Contributor Author

@naorpeled

@dwin-gharibi
dwin-gharibi force-pushed the fix/skip-keys-case-insensitive branch from 1f7ccff to c810105 Compare August 19, 2026 11:48
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit c810105

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 96d2687

@IsmaelMartinez
IsmaelMartinez force-pushed the fix/skip-keys-case-insensitive branch from 96d2687 to 6e1d1eb Compare August 20, 2026 16:46
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 6e1d1eb

@dwin-gharibi
dwin-gharibi force-pushed the fix/skip-keys-case-insensitive branch from 6e1d1eb to 92f5961 Compare August 21, 2026 07:01
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 92f5961

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving and merging. Verified before the merge: the full unit suite is green at 1,962 on your branch, and reverting pr_agent/algo/utils.py to the merge base while keeping your tests fails 2 of the 4, so the coverage genuinely bites.

That is nine of the twelve merged, and this one closes #2688. #2697 is the last one still open, with the scheme redaction suggestion sitting on the line ready to commit.

@IsmaelMartinez
IsmaelMartinez merged commit dbe881d into The-PR-Agent:main Aug 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The config skip-list comparison is case-sensitive, leaking keys it intends to hide

3 participants