cli: fix negated boolean options not removing implied options#56313
Open
islandryu wants to merge 4 commits intonodejs:mainfrom
Open
cli: fix negated boolean options not removing implied options#56313islandryu wants to merge 4 commits intonodejs:mainfrom
islandryu wants to merge 4 commits intonodejs:mainfrom
Conversation
islandryu
commented
Dec 19, 2024
src/node_options-inl.h
Outdated
Comment on lines
391
to
396
| std::string implied_name = name; | ||
| if (is_negation) { | ||
| // Implications for negated options are defined with "--no-". | ||
| implied_name.insert(2, "no-"); | ||
| } | ||
| auto implications = implications_.equal_range(implied_name); |
Member
Author
There was a problem hiding this comment.
Before the fix, there was likely code intended to apply negations to implications as well, but options with the --no- prefix were never added to the implications_.
4801938 to
6425807
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56313 +/- ##
==========================================
+ Coverage 88.00% 88.52% +0.51%
==========================================
Files 704 704
Lines 208739 208744 +5
Branches 40196 40276 +80
==========================================
+ Hits 183706 184782 +1076
+ Misses 16992 15970 -1022
+ Partials 8041 7992 -49
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Dec 28, 2024
jasnell
approved these changes
Dec 28, 2024
Member
|
@islandryu Can you please rebase? Also, is this semver-major? It does change existing functionality |
6425807 to
4559f70
Compare
islandryu
commented
Jan 8, 2026
Comment on lines
+435
to
+437
| default_field_map[value.name] = | ||
| *value.target_field | ||
| ->template Lookup<bool>(options); |
Member
Author
There was a problem hiding this comment.
I changed it so that it sets a default value instead of simply toggling a boolean.
Contributor
Failed to start CI⚠ Commits were pushed since the last approving review: ⚠ - cli: fix negated boolean options not removing implied options ⚠ - fix lint ⚠ - set default value when negated ⚠ - skip test if inspector disabled ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/20876405993 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using negated options for boolean options that imply other options (e.g., --inspect-brk), the implied options are not removed as expected. This causes the implied option to remain active, leading to unexpected behavior.
shimaryuuheinoMac-mini:node shimaryuuhei$ node --inspect-brk --no-inspect-brk -e "console.log(\"foo\")" Debugger listening on ws://127.0.0.1:9229/67479127-5d17-4027-b514-70217b2fe102 For help, see: https://nodejs.org/en/docs/inspector fooWhen using --no-inspect-brk, only the effect of the --inspect option remains.
This change ensures that when a negated option (e.g., --no-...) is used, any implied options are also removed. After this fix, the above example will no longer activate the implied options.
Alternative
Currently, the negated options affected by this change are not documented in the official CLI documentation: https://nodejs.org/api/cli.html
An alternative approach could be to remove these undocumented negated options entirely, ensuring no unexpected behavior arises from their usage.