Skip to content

Make every opt-out fail closed (0.8.0) - #51

Merged
dmccoystephenson merged 1 commit into
mainfrom
fix/opt-out-fails-closed
Nov 19, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
fix/opt-out-fails-closed

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

A server operator reported that usage reporting kept turning itself back on. Every way the client could read an opt-out as consent was audited, and each switch now fails closed: a value that does not clearly mean "on" turns reporting off.

Changes

Server-wide plugins/trace/config.yml (closes #15, closes #27, closes #42)

  • The value of enabled: is read as a YAML scalar, with quotes and any trailing comment stripped. Only true, on, yes or 1 keep reporting on.
  • A quoted "false", an empty enabled:, a comment-only value or a typo now disables.
  • Every enabled: line counts, so a later enabled: false is no longer shadowed by an earlier line.

Unreadable files (closes #40)

  • A file that exists but cannot be read now disables reporting, because it may say enabled: false.
  • A file that is not UTF-8 is read as ISO-8859-1 and is not appended to.
  • A file that is missing and cannot be created still counts as enabled, since the operator has said nothing.
  • A path the file system cannot represent also still counts as enabled.

Environment (closes #39)

  • TRACE_USAGE_REPORTING set to anything but blank or true/on/yes/1 disables. disabled and offline used to leave reporting on.
  • DO_NOT_TRACK set to anything but blank or 0/false/off/no disables.
  • An environment that cannot be read (for example, a SecurityManager denying getenv) disables instead of throwing out of build().

New: TraceClient.allowsReporting(Object)

  • Gives a program's own setting the same fail-closed parsing.
  • The README and Javadoc examples now use it instead of getBoolean(path, true). Bukkit's getBoolean returns its default for a quoted "false", so that pattern read an opt-out as on.

The version is bumped to 0.8.0, because values that used to leave reporting on now turn it off.

Tests

123 pass. The tests that pinned the old fail-open behaviour (...Yet, theFirstEnabledLineIsTheSwitch, valuesThatAreNotAnOptOutLeaveReportingOn) now assert the fail-closed behaviour. New tests cover an unreadable file, a non-UTF-8 file, an unreadable environment and allowsReporting.

The plugins that vendor this client will be updated to 0.8.0 and switched to allowsReporting in follow-up PRs.

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

A switch that does not clearly mean "on" now turns reporting off, so an
operator's opt-out can never be read as consent:

- Server-wide config: every enabled: line counts, its value is read as a
  YAML scalar (quotes and trailing comment stripped), and only true/on/yes/1
  keeps reporting on. A quoted "false", an empty enabled:, a typo, or any
  later enabled: false now disables (#15, #27).
- A server-wide file that exists but cannot be read now disables; one that
  is not UTF-8 is read as ISO-8859-1 and not appended to (#40). A file that
  is missing and cannot be created still counts as enabled.
- Environment: TRACE_USAGE_REPORTING set to anything but blank or a clear
  "on" disables; DO_NOT_TRACK set to anything but blank or a clear "no"
  disables; an environment that cannot be read disables (#39).
- New TraceClient.allowsReporting(Object) for a program's own setting, which
  fails closed the same way; the docs now use it instead of
  getBoolean(path, true), which reads a quoted "false" as on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 19, 2026
@dmccoystephenson
dmccoystephenson merged commit e653bbc into main Nov 19, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the fix/opt-out-fails-closed branch November 19, 2026 05:33
dmccoystephenson added a commit to Stephenson-Software/trace-client-csharp that referenced this pull request Nov 19, 2026
A switch that does not clearly mean "on" now turns reporting off, so an
opt-out can never be read as consent:

- Environment: TRACE_USAGE_REPORTING set to anything but blank or a clear
  "on" (true/on/yes/1) disables; DO_NOT_TRACK set to anything but blank or
  a clear "no" (0/false/off/no) disables. Before, only a fixed list of
  values disabled, so TRACE_USAGE_REPORTING=disabled or DO_NOT_TRACK=on
  left reporting on.
- An environment that cannot be read (e.g. a SecurityException in a
  sandbox) now disables; it used to leave reporting on.
- New TraceClient.AllowsReporting(object) for a program's own setting:
  only true, or a string true/on/yes/1, allows reporting; anything else,
  including null, a number or a quoted "false", turns it off. The README
  and doc-comment examples now pass the setting through it.

Counterpart of Stephenson-Software/trace-client-java#51.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
dmccoystephenson added a commit to Stephenson-Software/trace-client-cpp that referenced this pull request Nov 19, 2026
A switch that does not clearly mean "on" now turns reporting off, so an
opt-out can never be read as consent:

- Environment: TRACE_USAGE_REPORTING set to anything but blank or a clear
  "on" (true/on/yes/1) disables; DO_NOT_TRACK set to anything but blank or
  a clear "no" (0/false/off/no) disables. Before, only a fixed list of
  values disabled, so TRACE_USAGE_REPORTING=disabled or DO_NOT_TRACK=on
  left reporting on. An environment that cannot be read now disables.
- New trace_client::allowsReporting(value) for a program's own setting:
  only true, or a string true/on/yes/1, allows reporting; anything else,
  including a null pointer, a number or a quoted "false", turns it off.
  The README and header examples now pass the setting through it.

Counterpart of Stephenson-Software/trace-client-java#51.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment