Skip to content

Fix false booleans in config file being parsed as true - #8053

Merged
code-asher merged 1 commit into
coder:mainfrom
harshbhx:fix/8049-config-false-booleans
Oct 14, 2026
Merged

code-asher merged 1 commit into
coder:mainfrom
harshbhx:fix/8049-config-false-booleans

Conversation

@harshbhx

@harshbhx harshbhx commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8049

Summary

Boolean options set to false in config.yaml were being treated as true. This PR makes parse() ignore booleans whose value is false, the same way it already ignores optional strings set to false.

Problem

parseConfigFile() turns each config entry into a CLI-style flag (src/node/cli.ts#L815-L824):

config.yaml Generated flag
enable-remote-storage: true --enable-remote-storage
enable-remote-storage: false --enable-remote-storage=false

parse() then sets any boolean option it sees to true, without looking at the value (src/node/cli.ts#L438-L441):

if (option.type === "boolean") {
  ;(args[key] as boolean) = true
  continue
}

So writing false in the config file silently does the opposite of what the user asked. This affects every boolean option, for example disable-telemetry, disable-update-check, disable-workspace-trust and enable-remote-storage (the case reported in #7914).

Solution

Skip the assignment when a boolean's value is "false":

if (option.type === "boolean") {
  // Booleans set to false (for example `--flag=false`, which is also how
  // false values from the config file are passed in) are ignored.
  if (value !== "false") {
    ;(args[key] as boolean) = true
  }
  continue
}

Why this approach

  • It follows existing behavior: optional strings set to false are already ignored in the same function (#L460), and there's a test for it (--cert=false → {}).
  • The fix lives in the shared parser rather than only in parseConfigFile(), so --flag=false on the command line now works too instead of enabling the flag.
  • Leaving the key unset (rather than setting it to false) keeps the existing merge semantics between the config file and CLI args untouched.

Changes

File Change
src/node/cli.ts Ignore boolean options whose value is false (+5 / −1)
test/unit/node/cli.test.ts Two new unit tests (+13)

Before / After

config.yaml:

disable-telemetry: false
disable-update-check: true
Parsed result
Before { "disable-telemetry": true, "disable-update-check": true } ❌
After { "disable-update-check": true } ✅

How to test

  1. Add enable-remote-storage: false (or any boolean option set to false) to ~/.config/code-server/config.yaml.
  2. Start code-server without overriding that option on the command line.
  3. Before: the option is enabled. After: it stays disabled.
  4. Optionally, run code-server --disable-telemetry=false and confirm telemetry is no longer disabled.

Testing done

  • should ignore booleans set to false: parse(["--disable-telemetry=false"]) returns {}.
  • should parse booleans set to false in the config file: a config with one false and one true boolean only keeps the true one.
  • Both new tests fail without the fix and pass with it.
  • Full unit suite: 347 / 347 passed (npm run test:unit).
  • Prettier, ESLint and tsc --noEmit are clean.
  • Not tested end to end in a running code-server instance (the change is limited to argument parsing, which the unit tests cover directly).

Notes for reviewers

  • Behavior change: anyone who has some-flag: false in their config and was (unknowingly) relying on it being enabled will now get it disabled, which is what their config says. I'd consider this a bug fix, but it may be worth a changelog note.
  • The commit is signed, as required by the contributing guide.

Options like `enable-remote-storage: false` in config.yaml are converted to
`--enable-remote-storage=false`, but the parser set any boolean option to
true regardless of its value. Booleans set to false are now ignored, the
same way optional strings set to false already are.

Fixes coder#8049
Copilot AI balanced review requested due to automatic review settings October 13, 2026 20:33
@harshbhx
harshbhx requested a review from a team as a code owner October 13, 2026 20:33

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.

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@code-asher
code-asher merged commit 83670e5 into coder:main Oct 14, 2026
10 checks passed
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.

Boolean options set to false in config.yaml are parsed as true

3 participants