Repository navigation
fix: keep usage reporting off once an operator turns it off - #205
Merged
Merged
Conversation
An opt-out could be lost three ways: a quoted "false" read as on by getBoolean(), a config.yml with a YAML error overwritten with the bundled defaults on startup, and a hand edit made while running overwritten by the stale loaded config on the next /at config set, autosave or shutdown. - saveConfig() is overridden so every save skips an unparseable file and keeps an opt-out found on disk (unless /at config set usage-reporting.enabled is what changed). - The autosave/shutdown no longer re-save config.yml. - The switch is read with UsageReportingSetting.isEnabled (fails closed). - /at config set refuses a whole section. - Vendored trace client re-vendored at 0.8.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
/at config set usage-reporting.enabled false now replaces the running client with TraceClient.disabled() and closes the old one, instead of reporting until the next restart. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bukkit drops a key with no value when it loads config.yml, so the bundled enabled: true used to win over an operator who blanked the switch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
It was reported that usage reporting kept turning itself back on after being disabled. Every way ActivityTracker could read an operator's opt-out as "on", or write "on" back over it, was audited.
What was found
"false"was read as on.getBoolean("usage-reporting.enabled")returns the bundled default (true) for a string or any other non-boolean value.config.ymlwas overwritten on startup. Bukkit loads aconfig.ymlwith a YAML error as empty, so every key falls back to the jar defaults.saveMissingConfigDefaultsIfNotPresent()then copied the defaults in and saved on every enable, replacing the operator's whole file, opt-out included, withenabled: true.enabled: falsewritten by hand while the server was running was overwritten by the next/at config set, and by every autosave and the shutdown save after any/at config setthat session./at config set usage-reporting falsereplaced the whole block with a string, after which its keys read as the bundled defaults (on).Changes
ActivityTrackeroverridessaveConfig(), so every caller is guarded. Aconfig.ymlthat cannot be parsed is never written (a SEVERE line is logged and reporting is off), and an opt-out on disk is carried into the loaded config before saving. The only exception is/at config set usage-reporting.enabled, which may turn reporting back on.StorageService.save()(autosave andonDisable) no longer savesconfig.yml./at config setalready saves each change, so this only re-saved already-saved changes.ConfigService.isUsageReportingEnabled()usesUsageReportingSetting.isEnabled(...), which fails closed (onlytrue/on/yes/1) and lets an opt-out on disk win over the loaded copy./at config set usage-reporting.enabled falsestops reporting at once: the running client is replaced withTraceClient.disabled()and closed. Turning it back on still waits for a restart, and the reply says so./at config setrefuses a whole configuration section.Tests
mvn test: 396 pass, 0 fail. NewUsageReportingSettingTest(8) covers the following:"false"and an unrecognised value are offNew
ConfigServiceTestcases cover the quoted"false", an on-disk opt-out winning, which saves may change the switch, turning reporting off in-game stopping it at once, and refusing a section. The vendoredTraceClientTest(123) passes at 0.8.0.🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson