Fix --idle-timeout-seconds validation being skipped - #8009
Open
Dev-next-gen wants to merge 1 commit into
Open
Conversation
The lower bound check ran before the parser had resolved the value, so it only saw a value with the --idle-timeout-seconds=<value> form. With the space-separated form the value was still undefined at that point, Number(undefined) is NaN, and NaN <= 60 is false, so anything got through. Move the check below the block that pulls the value from the next argument so both forms are validated the same way.
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.
Fixes #
No issue; this is a minor fix, so I did not open one first.
I was reading through
parseinsrc/node/cli.tsand noticed that the lower boundcheck for
--idle-timeout-secondssits above the block that resolves the value:At that point
valueis only set for the--idle-timeout-seconds=<value>form. With thespace-separated form it is still
undefined,Number(undefined)isNaN, andNaN <= 60is false, so the check never fires. On main:
The config file goes through
parsewith--key=valueand theCODE_SERVER_IDLE_TIMEOUT_SECONDSbranch has its own check, so both of those alreadyreject values of 60 or less. Only the space-separated flag slipped past.
The fix moves the same three lines below the value resolution, so both flag forms are
validated identically. I did not change the condition or the message.
I added a unit test to
test/unit/node/cli.test.tscovering both forms plus an acceptedvalue. It fails on main on the space-separated case only:
and passes with the change. The whole unit suite is green with it (23 suites, 343 tests).
Two things worth flagging, since you may see them differently than I do:
--idle-timeout-seconds 30used to be accepted and nowerrors out at startup. I took that as the point of the fix, since the same value is
already rejected through the config file and the environment variable, but it will be
visible to anyone who happened to rely on the flag form.
"Fix incorrect data path being used" (Fix incorrect data path being used #7991) did. Happy to drop it if you would rather
keep the changelog for release-time edits.
AI tools used