From 267d140a771e939deb96fade5b10e9be029241eb Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Thu, 19 Nov 2026 22:35:47 -0700 Subject: [PATCH] Describe usage reporting's fail-closed switch accurately in TESTING.md 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 --- README.md | 3 ++- docs/TESTING.md | 12 ++++++++++-- gardener/usage.py | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d9806cc..b27aab6 100644 --- a/README.md +++ b/README.md @@ -275,7 +275,8 @@ Every switch fails closed, so an opt-out is never read as "on": `GARDENER_USAGE_REPORTING_ENABLED`, once set (in the environment or `notify.env`, even blank), keeps reporting on only for `true`, `on`, `yes` or `1` (any case); anything else — empty, a typo — turns it off, and so does a -`notify.env` that exists but cannot be read. `TRACE_USAGE_REPORTING` set to +`notify.env` that exists but cannot be read, unless the environment variable +itself says on. `TRACE_USAGE_REPORTING` set to anything but blank or one of those values turns it off, as does `DO_NOT_TRACK` set to anything but blank, `0`, `false`, `off` or `no`. An opt-out written under another spelling counts as off too and wins over the real setting: diff --git a/docs/TESTING.md b/docs/TESTING.md index b54a283..ab22d5d 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -252,8 +252,16 @@ loopback `http.server` started in the test (never the real trace service): the three `GARDENER_USAGE_REPORTING_*` settings' precedence (env var, then the same name in `notify.env` under a tmp `GARDENER_STATE_DIR`, then the built-in -default; a blank value falls through, only an explicit `0/false/no/off` -opts out, an unreadable file degrades to a stderr warning), that the +default; a blank value falls through), that the enabled switch fails +closed (in the environment or `notify.env`, only `true/on/yes/1` keeps +reporting on: blank everywhere, a typo or `disabled` is off; a `notify.env` +that exists but cannot be read is off with a stderr warning unless the +environment says on, while endpoint and key fall back to their defaults), +that an opt-out under a near-miss name (`GARDENER_USAGE_REPORTING=off`, +`..._ENABLE=false`, lower-case or hyphenated spellings, `..._DISABLED=true`) +is off and wins over the real switch saying on, while near-miss names that +say on, the endpoint/key settings and other programs' switches in the +environment are not read as an opt-out, that the `startup` body is exactly `application`/`name`/three tags (`version`, `service`, `install`) with nothing about the machine or the run in it, that the installation ID file lives in the state dir and is reused, that diff --git a/gardener/usage.py b/gardener/usage.py index aa6b979..924242c 100644 --- a/gardener/usage.py +++ b/gardener/usage.py @@ -41,7 +41,8 @@ setting is read through the client's ``allows_reporting``, so once it is set (in the environment or in ``notify.env``, even to a blank value) only true/on/yes/1 keeps reporting on; and a ``notify.env`` that exists but cannot -be read turns reporting off, since it may hold the opt-out. So does an +be read turns reporting off unless the environment variable says on, since it +may hold the opt-out. So does an opt-out written under another spelling (``GARDENER_USAGE_REPORTING=off``, ``GARDENER_USAGE_REPORTING_ENABLE=false``, ``gardener_usage_reporting_enabled=no``,