Skip to content

Make every opt-out fail closed (0.5.0) - #45

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

Every opt-out now fails closed: a switch that does not clearly mean "on" turns usage reporting off, so a disabled setting can never be read as consent. This is the Python counterpart of Stephenson-Software/trace-client-java#51 (0.8.0).

Fail-open paths fixed

  • TRACE_USAGE_REPORTING only turned reporting off for off/false/0/no; disabled or a typo left it on. Now anything but blank or true/on/yes/1 turns it off.
  • DO_NOT_TRACK only turned reporting off for 1/true/yes. Now anything but blank or 0/false/off/no turns it off.
  • An environment that could not be read (or held a non-string value) raised out of the constructor. It now counts as opting out.
  • enabled= was a truthiness check, so enabled="false" (a string from a config file) reported. It is now read through allows_reporting(): only True or a string true/on/yes/1 is on; None, numbers, typos and "false" are off. Leaving it out still defaults to on.

New helper

allows_reporting(setting) (exported from trace_client), the equivalent of TraceClient.allowsReporting(Object) in Java. The README "Turning it off" section documents it and the README examples pass the program's own flag through it.

The client reads no config-file switch of its own (the install-ID file holds only an ID), so the file rules do not apply.

Version

0.4.2 → 0.5.0 in pyproject.toml, __version__ and both module headers. No CHANGELOG in this repo.

Tests

python -m unittest: 85 tests, OK. Tests pinning the fail-open environment values were updated; new tests cover unfamiliar TRACE_USAGE_REPORTING/DO_NOT_TRACK values, an unreadable environment, allows_reporting, and enabled= strings/None/numbers.

🤖 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
opt-out can never be read as consent (trace-client-java 0.8.0 counterpart):

- TRACE_USAGE_REPORTING set to anything but blank or true/on/yes/1 now
  disables; only off/false/0/no did, so "disabled" or a typo left it on.
- DO_NOT_TRACK set to anything but blank or 0/false/off/no now disables;
  only 1/true/yes did.
- An environment that cannot be read (or holds a non-string value) now
  disables instead of raising out of the constructor.
- enabled= is read through the new allows_reporting(), so enabled="false",
  None or 0 is off; it used to be any truthy value, so the string "false"
  reported.
- New allows_reporting(setting): True only for True or a string
  true/on/yes/1; README examples use it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant