Title: Fix false booleans in config file being parsed as true by harshbhx · Pull Request #8053 · coder/code-server · GitHub
Open Graph Title: Fix false booleans in config file being parsed as true by harshbhx · Pull Request #8053 · coder/code-server
X Title: Fix false booleans in config file being parsed as true by harshbhx · Pull Request #8053 · coder/code-server
Description: 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 Add enable-remote-storage: false (or any boolean option set to false) to ~/.config/code-server/config.yaml. Start code-server without overriding that option on the command line. Before: the option is enabled. After: it stays disabled. 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.
Open Graph Description: 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 stri...
X Description: 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 stri...
Opengraph URL: https://github.com/coder/code-server/pull/8053
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:24d302c6-0cb6-7d48-417e-f2fa9bf423dd |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D688:2463BD:2F71403:3C9AFE9:6B01B8B1 |
| html-safe-nonce | 2321daa28e94922e39cac6ccec589650ec1b13f273efd497a3ef758d6945e1ba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjg4OjI0NjNCRDoyRjcxNDAzOjNDOUFGRTk6NkIwMUI4QjEiLCJ2aXNpdG9yX2lkIjoiNDU5ODYwMTM2MzcwMDY5MzE2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4514e4e0e20607add94120eb9315cb659e462722d97464e011a42eba70b455e9 |
| hovercard-subject-tag | pull_request:4849121778 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/coder/code-server/pull/8053/files |
| twitter:image | https://avatars.githubusercontent.com/u/155092207?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/155092207?s=400&v=4 |
| og:image:alt | 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 stri... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/coder/code-server git https://github.com/coder/code-server.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 172953845 |
| octolytics-dimension-repository_nwo | coder/code-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172953845 |
| octolytics-dimension-repository_network_root_nwo | coder/code-server |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width