Skip to content

Commit 8a7bf87

Browse files
authored
Fix --idle-timeout-seconds validation being skipped (#8009)
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.
1 parent cd0f21d commit 8a7bf87

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ Code v99.99.999
2222

2323
## Unreleased
2424

25+
### Fixed
26+
27+
- `--idle-timeout-seconds` was only validated when passed as `--idle-timeout-seconds=<value>`;
28+
values of 60 or less passed as `--idle-timeout-seconds <value>` were silently accepted.
29+
2530
## [4.138.0](https://github.com/coder/code-server/releases/tag/v4.138.0) - 2026-09-19
2631

2732
Code v1.138.0

‎src/node/cli.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,6 @@ export const parse = (
429429
throw new Error("--github-auth can only be set in the config file or passed in via $GITHUB_TOKEN")
430430
}
431431

432-
if (key === "idle-timeout-seconds" && Number(value) <= 60) {
433-
throw new Error("--idle-timeout-seconds must be greater than 60 seconds.")
434-
}
435-
436432
const option = options[key]
437433
if (option.type === "boolean") {
438434
;(args[key] as boolean) = true
@@ -452,6 +448,10 @@ export const parse = (
452448
throw error(`--${key} requires a value`)
453449
}
454450

451+
if (key === "idle-timeout-seconds" && Number(value) <= 60) {
452+
throw new Error("--idle-timeout-seconds must be greater than 60 seconds.")
453+
}
454+
455455
if (option.type === OptionalString && value === "false") {
456456
continue
457457
}

‎test/unit/node/cli.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,16 @@ describe("parser", () => {
268268
expect(() => parse(["--log", "invalid"])).toThrowError(/--log valid values: \[trace, debug, info, warn, error\]/)
269269
})
270270

271+
it("should error if idle-timeout-seconds is too low", () => {
272+
expect(() => parse(["--idle-timeout-seconds=60"])).toThrowError(
273+
/--idle-timeout-seconds must be greater than 60 seconds/,
274+
)
275+
expect(() => parse(["--idle-timeout-seconds", "60"])).toThrowError(
276+
/--idle-timeout-seconds must be greater than 60 seconds/,
277+
)
278+
expect(parse(["--idle-timeout-seconds", "61"])).toEqual({ "idle-timeout-seconds": 61 })
279+
})
280+
271281
it("should error if the option doesn't exist", () => {
272282
expect(() => parse(["--foo"])).toThrowError(/Unknown option --foo/)
273283
})

0 commit comments

Comments
 (0)