fix(cli-repl): correctly return false from enableTelemetry setting when forceDisableTelemetry is set MONGOSH-1141 - #2770
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the CLI REPL configuration behavior so that when forceDisableTelemetry is in effect, querying enableTelemetry reflects the enforced runtime state (i.e., returns false) rather than the user preference value, preventing misleading configuration output.
Changes:
- Special-case
getConfig('enableTelemetry')to returnfalsewhenforceDisableTelemetryis set. - Refactor the
setConfig('enableTelemetry', ...)guard to run before mutating config state (behavior preserved, but clearer control flow). - Add a regression test ensuring
config.get("enableTelemetry")printsfalseunder a globalforceDisableTelemetry: trueconfig.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/cli-repl/src/cli-repl.ts | Ensures enableTelemetry reads as false when telemetry is force-disabled; keeps writes blocked. |
| packages/cli-repl/src/cli-repl.spec.ts | Adds coverage verifying config.get("enableTelemetry") returns false under forced-disable telemetry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Can we leverage your PR to clean up this? :) https://github.com/mongodb-js/mongosh/blob/main/packages/cli-repl/src/cli-repl.ts#L221-L224 or crate a follow-up PR/ticket to not forget again. Would be great to introduce a single |
|
Yea that's fair, I'll investigate what that would take |
|
Because of async-ness I had to change some functions return type, what do we think? @alenakhineika |
alenakhineika
left a comment
There was a problem hiding this comment.
This is great 🙌 Thx!
…en forceDisableTelemetry is set MONGOSH-1141
When
forceDisableTelemetryis set don't consult the user preferences just return false. Fixes misleading state.