Skip to content

fix: support duplicate option names with different values#214

Merged
richm merged 1 commit into
linux-system-roles:mainfrom
richm:fix-dup-minimal
Jun 1, 2026
Merged

fix: support duplicate option names with different values#214
richm merged 1 commit into
linux-system-roles:mainfrom
richm:fix-dup-minimal

Conversation

@richm
Copy link
Copy Markdown
Contributor

@richm richm commented May 29, 2026

Cause: The code would only use the last option if multiple options were passed with the same
name but different values.

Consequence: The user cannot configure the kernel command line with multiple options having
different values e.g. "console=tty0 console=ttyS0"

Fix: Ensure that multiple duplicate options with different values can be passed.

Result: User can configure the kernel command line with multiple duplicate options
with different values.

Signed-off-by: Rich Megginson rmeggins@redhat.com

Assisted-by: Cursor IDE using the models Composer 2.5, Codex 5.3, and Sonnet 4.6

Summary by CodeRabbit

  • Bug Fixes

    • Duplicate bootloader option names are now detected and reconciled so kernel arguments are consolidated into a single coherent set, avoiding inconsistent or duplicate tokens and preventing unnecessary updates.
  • Tests

    • Added unit tests covering detection of duplicate option names and the resulting bootloader argument modification behavior to prevent regressions.

Review Change Stack

@richm richm requested a review from spetrosi as a code owner May 29, 2026 19:05
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3067bcde-1357-4d77-9e21-4559687cd884

📥 Commits

Reviewing files that changed from the base of the PR and between 62d5bac and 5e858f8.

📒 Files selected for processing (2)
  • library/bootloader_settings.py
  • tests/unit/test_bootloader_settings.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/unit/test_bootloader_settings.py
  • library/bootloader_settings.py

📝 Walkthrough

Walkthrough

This PR detects duplicated non-absent bootloader option names, reconciles kernel grubby args to the deduplicated expected tokens, and adds unit tests covering detection and mod_boot_args command generation scenarios.

Changes

Duplicate bootloader option handling

Layer / File(s) Summary
Duplicate detection helper and tests
library/bootloader_settings.py, tests/unit/test_bootloader_settings.py
Adds generated-file header and get_duplicate_present_option_names() plus find_boot_arg_tokens() to identify duplicated "present" option names and extract matching grubby tokens. Adds test_get_duplicate_present_option_names.
mod_boot_args duplicate reconciliation
library/bootloader_settings.py, tests/unit/test_bootloader_settings.py
Extends mod_boot_args() to reconcile duplicated non-absent option names by comparing expected deduplicated tokens with currently-present kernel args and generating removal/addition grubby commands as needed. Adds test_duplicate_option_names exercising missing, partial, full, and identical-duplicate scenarios.
🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description Format ⚠️ Warning PR description uses "Cause:", "Consequence:", "Fix:", "Result:" instead of required "Enhancement:"/"Feature:", "Reason:", "Result:" from template. Rewrite PR description to follow template: start with "Enhancement:" or "Feature:", include "Reason:" section, and keep "Result:" section.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title follows Conventional Commits format with type 'fix' and a clear description of the change.
Description check ✅ Passed The pull request description covers cause, consequence, fix, and result sections, providing clear context for the changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.94%. Comparing base (63d7c0c) to head (5e858f8).
⚠️ Report is 119 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #214      +/-   ##
==========================================
+ Coverage   78.43%   79.94%   +1.51%     
==========================================
  Files           2        3       +1     
  Lines         255      344      +89     
==========================================
+ Hits          200      275      +75     
- Misses         55       69      +14     
Flag Coverage Δ
sanity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@richm richm force-pushed the fix-dup-minimal branch 2 times, most recently from f52c098 to 62d5bac Compare May 29, 2026 19:35
@richm
Copy link
Copy Markdown
Contributor Author

richm commented May 29, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@library/bootloader_settings.py`:
- Around line 327-351: Run the style checks (tox -e black,flake8) and fix PEP8
violations: move any module-level imports currently located mid-file up to the
top of the module to resolve E402, and wrap or reformat long lines to be under
79/88 chars to resolve E501; specifically inspect and reformat code around the
functions get_duplicate_present_option_names and find_boot_arg_tokens (and
surrounding code) so their logic remains identical but line lengths and import
positions comply with Black/flake8, then re-run black to ensure consistent
formatting.
- Around line 344-351: The regex pattern in find_boot_arg_tokens concatenates
the raw name into the pattern, so metacharacters in the option name (e.g., dots)
can change matching; update the pattern construction to use an escaped version
of name (e.g., re.escape(name)) when building pattern so dots and other regex
metacharacters are treated literally, while preserving the existing overall
pattern logic (the function find_boot_arg_tokens and its pattern variable are
where to change).

In `@tests/unit/test_bootloader_settings.py`:
- Around line 457-589: Several test lines exceed the 79-char limit (E501) in
tests like test_get_duplicate_present_option_names and
test_duplicate_option_names where long literal strings and
assert_called_once_with arguments (e.g., the "grubby --update-kernel=ALL ..."
calls and the multi-line info_* vars) are used; shorten them by breaking long
strings into implicit adjacent literals or concatenating with +, wrap long
command/assert strings across multiple quoted parts, or use dedented short
variables (e.g., info_empty_args, info_one_console, info_both_consoles) split
into multiple shorter lines so each line is <=79 chars, then run tox -e
black,flake8 to verify compliance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ed8b95d8-5871-4176-89bc-0ea455f78d0c

📥 Commits

Reviewing files that changed from the base of the PR and between 647a40e and 62d5bac.

📒 Files selected for processing (2)
  • library/bootloader_settings.py
  • tests/unit/test_bootloader_settings.py

Comment thread library/bootloader_settings.py
Comment thread library/bootloader_settings.py
Comment thread tests/unit/test_bootloader_settings.py
@richm richm force-pushed the fix-dup-minimal branch from 62d5bac to 9a58caa Compare May 29, 2026 20:35
@richm
Copy link
Copy Markdown
Contributor Author

richm commented May 29, 2026

[citest]

@richm
Copy link
Copy Markdown
Contributor Author

richm commented May 29, 2026

fixes #191

Cause: The code would only use the last option if multiple options were passed with the same
name but different values.

Consequence: The user cannot configure the kernel command line with multiple options having
different values e.g. "console=tty0 console=ttyS0"

Fix: Ensure that multiple duplicate options with different values can be passed.

Result: User can configure the kernel command line with multiple duplicate options
with different values.

Assisted-by: Cursor IDE using the models Composer 2.5, Codex 5.3, and Sonnet 4.6

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm richm force-pushed the fix-dup-minimal branch from 9a58caa to 5e858f8 Compare May 29, 2026 22:06
@richm
Copy link
Copy Markdown
Contributor Author

richm commented May 29, 2026

[citest]

@richm richm merged commit 42ef098 into linux-system-roles:main Jun 1, 2026
46 checks passed
@richm richm deleted the fix-dup-minimal branch June 1, 2026 14:40
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.

2 participants