Skip to content

fix: keep usage reporting off once it is turned off - #263

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

Summary

A server operator reported usage reporting turning itself back on after being disabled. Two fail-open paths in gardener's own switch are fixed here, along with the vendored client.

  • Unreadable notify.env read as on: when notify.env existed but could not be read, it was treated as empty, so GARDENER_USAGE_REPORTING_ENABLED=false in it was ignored and reporting came back on (a unit test pinned this). A file that cannot be read (OSError, or a decode error) now turns reporting off, since it may hold the opt-out; endpoint and key still fall back to their defaults. An explicit true in the environment still wins, as an operator action.
  • Only four values were off: the setting was compared with not in {0,false,no,off}, so a typo or disabled left reporting on. It is now read through the client's allows_reporting: only true/on/yes/1 keeps reporting on. A blank env var still falls through to notify.env (the documented precedence), but a value present-and-blank with nothing behind it is now off rather than on. Unset everywhere still means the default, on.
  • Vendored client: trace-client-python 0.4.1 -> 0.5.0 (Make every opt-out fail closed (0.5.0) trace-client-python#45, not yet released), unmodified apart from the vendoring note. TRACE_USAGE_REPORTING set to anything but blank or an on-value, DO_NOT_TRACK set to anything but blank or 0/false/off/no, or an unreadable environment, now turns reporting off.
  • Tests: test_only_an_explicit_no_turns_it_off and test_a_missing_or_unreadable_config_file_means_defaults (which pinned the old behaviour) are replaced by fail-closed tests for the env var, notify.env, unclear client-wide values and an unreadable file. tests/test_trace_client.py updated to the 0.5.0 rules with tests for allows_reporting, unclear environment values, an unreadable environment and enabled="false".
  • README (usage reporting) and docs/TESTING.md updated.

Tests

  • PYTHONPATH=. python3.11 -m unittest discover -s tests: 1392 tests, OK (2 skipped).
  • integration.test_offline_observability (includes the usage-reporting opt-out end to end): 12 tests, OK.

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

GARDENER_USAGE_REPORTING_ENABLED was off only for 0/false/no/off: a typo or
"disabled" left reporting on, and a notify.env that existed but could not be
read was treated as empty - so a file holding the opt-out turned reporting
back on. The setting is now read through the trace client's
allows_reporting and fails closed: only true/on/yes/1 keeps reporting on,
a value set blank everywhere is off, and an unreadable notify.env is off.
Unset everywhere still means on.

Re-vendors trace-client-python 0.5.0, whose TRACE_USAGE_REPORTING /
DO_NOT_TRACK checks fail closed too; tests that pinned the old behaviour are
updated. README and docs/TESTING.md updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson
dmccoystephenson merged commit ff1a2ef into main Nov 19, 2026
5 checks passed
@dmccoystephenson
dmccoystephenson deleted the fix/opt-out-fails-closed branch November 19, 2026 05:57
dmccoystephenson added a commit that referenced this pull request Nov 20, 2026
#265)

docs/TESTING.md still said only an explicit 0/false/no/off opts out and an
unreadable notify.env just warns, which #263 and #264 changed: the switch
fails closed, an unreadable notify.env is off, and near-miss opt-out
spellings count as off. README and usage.py's docstring now also say that
an environment variable saying on wins over an unreadable notify.env, as
tests/test_usage.py asserts.

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