Skip to content

fix: keep usage reporting off once an operator turns it off - #205

Merged
dmccoystephenson merged 3 commits into
mainfrom
fix/usage-reporting-opt-out-sticky
Nov 19, 2026
Merged

dmccoystephenson merged 3 commits into
mainfrom
fix/usage-reporting-opt-out-sticky

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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

  1. A quoted "false" was read as on. getBoolean("usage-reporting.enabled") returns the bundled default (true) for a string or any other non-boolean value.
  2. An unparseable config.yml was overwritten on startup. Bukkit loads a config.yml with 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, with enabled: true.
  3. A stale in-memory config was written over a hand edit. An enabled: false written 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 set that session.
  4. /at config set usage-reporting false replaced the whole block with a string, after which its keys read as the bundled defaults (on).

Changes

  • ActivityTracker overrides saveConfig(), so every caller is guarded. A config.yml that 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 and onDisable) no longer saves config.yml. /at config set already saves each change, so this only re-saved already-saved changes.
  • ConfigService.isUsageReportingEnabled() uses UsageReportingSetting.isEnabled(...), which fails closed (only true/on/yes/1) and lets an opt-out on disk win over the loaded copy.
  • /at config set usage-reporting.enabled false stops reporting at once: the running client is replaced with TraceClient.disabled() and closed. Turning it back on still waits for a restart, and the reply says so.
  • /at config set refuses a whole configuration section.
  • The vendored trace client (and its test) is re-vendored at 0.8.0 (Make every opt-out fail closed (0.8.0) Stephenson-Software/trace-client-java#51), whose server-wide and environment opt-outs also fail closed.
  • CHANGELOG and CONFIG.md updated.

Tests

mvn test: 396 pass, 0 fail. New UsageReportingSettingTest (8) covers the following:

  • an upgrade keeps reporting off
  • a quoted "false" and an unrecognised value are off
  • a stale save keeps an opt-out made while running
  • an unparseable file is never overwritten and reporting is off
  • a missing file is not an opt-out
  • the operator can still turn reporting on with a command

New ConfigServiceTest cases 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 vendored TraceClientTest (123) passes at 0.8.0.

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

dmccoystephenson and others added 3 commits November 18, 2026 21:03
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]>
@dmccoystephenson
dmccoystephenson merged commit 9ac631a into main Nov 19, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the fix/usage-reporting-opt-out-sticky branch November 19, 2026 05:36
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.

1 participant