Skip to content

Commit b56a3df

Browse files
Teach both installers the telemetry opt-out's new name
The binary's opt-out was renamed from `DISABLE_TELEMETRY` to `MAPBOX_CLI_NO_TELEMETRY` and the break was documented honestly. Both installers were left on the old name, so after that release neither variable silenced both halves: the documented one stopped the CLI's markers but not the installer's, and the old one did the reverse. `docs/distribution.md` in the private repo already claimed the fix — "`MAPBOX_CLI_NO_TELEMETRY` switches all of that off … Both installers carry their own copy of this logic, and both test suites pin it in both directions." The first half was false and the second pinned the wrong name. This makes that documentation true rather than changing it. **The old name keeps working here, and only here.** The binary's break was announced in a changelog someone upgrading can read. An installer is fetched and executed in one line — `curl … | sh`, `irm … | iex` — so its reader has no release notes in front of them, and breaking an opt-out is the one change that must not happen quietly. Asymmetric on purpose, and the comment in each file says so. When both are set the new name wins, including when it declines: an explicit `MAPBOX_CLI_NO_TELEMETRY=0` beats a stale `DISABLE_TELEMETRY=1` left in an image from before the rename. Without that the old variable could never be retired. Verified rather than reasoned about: each script's decision block was run over the cases directly — nine in `sh`, eight in `pwsh` 7.6.6 — covering both names, both precedence directions, the six false spellings, an unknown spelling, whitespace, and a set-but-empty new name as a deliberate clear. Both real harnesses then got cases asserting the new name opts out, wins when the two disagree, and wins in the opt-out direction too. `test-install.sh` reports all cases passed; `test-install.ps1` reports all good. Ported from mapbox/mapbox-cli-private#141, which cannot merge there now that `oss/` is a submodule (mapbox/mapbox-cli-private#132). That PR also edited `docs/distribution.md`, which lives in the private repo and stays there.
1 parent a4fb834 commit b56a3df

5 files changed

Lines changed: 143 additions & 26 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ breaking is [written down in CONTRIBUTING.md](CONTRIBUTING.md#compatibility) —
1010
command names, flags, the two output modes and the exit codes are promises;
1111
the Mapbox APIs' own response bodies are not.
1212

13+
## Unreleased
14+
15+
### Changed
16+
17+
- Both installers now honour `MAPBOX_CLI_NO_TELEMETRY`, the name the binary
18+
reads. They were left on the old `DISABLE_TELEMETRY` when the binary was
19+
renamed, so neither name silenced both halves: the documented variable
20+
stopped the CLI's markers but not the installer's, and the old one did the
21+
reverse. `DISABLE_TELEMETRY` keeps working **in the installers only** — the
22+
binary's break was announced, and a script fetched and run in one line has
23+
no release notes in front of the reader, so breaking an opt-out there would
24+
have happened silently. When both are set the new name wins.
25+
1326
## 0.1.8 - 2026-09-14
1427

1528
Initial beta release. The next release is `0.2.0`.

‎scripts/install.ps1‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,33 @@
8686
# because this value comes from the environment and ends up in a header.
8787
$InstallSource = $env:MAPBOX_CLI_INSTALL_SOURCE
8888

89-
# The switch src/http.rs honours for the CLI's own User-Agent, read here
90-
# the same way, because someone who put DISABLE_TELEMETRY=1 in a Dockerfile
91-
# and then runs `irm ... | iex` in the same file has already said which way
92-
# they want it. The product token above survives it - the equivalent of
89+
# The switch src/telemetry.rs honours for the CLI's own User-Agent, read
90+
# here the same way, because someone who put it in a Dockerfile and then
91+
# runs `irm ... | iex` in the same file has already said which way they
92+
# want it. The product token above survives it - the equivalent of
9393
# `mapbox-cli/<version>` going out either way - and the triple and the
9494
# source tag are what it drops.
9595
#
96+
# Two names, and only the binary dropped the old one.
97+
# MAPBOX_CLI_NO_TELEMETRY is the documented switch; DISABLE_TELEMETRY is
98+
# what it was called before, and this script still honours it. The rename
99+
# was announced as breaking for the binary; nothing announced it for the
100+
# installers, which are fetched and run in one line with no release notes
101+
# in front of the reader - and breaking an opt-out is the one change that
102+
# must not happen quietly. So both work here, and the new name wins when
103+
# both are set. See mapbox/mapbox-cli-private#140.
104+
#
96105
# Unset, empty or whitespace is a cleared variable. `0`, `f`, `false`, `n`,
97106
# `no` and `off` are clap's false spellings, the same reading this script
98-
# already gives MAPBOX_NO_MODIFY_PATH, so DISABLE_TELEMETRY=0 is someone
99-
# declining the opt-out rather than taking it. Anything else opts out,
100-
# including a spelling nobody planned for: the safe reading of a value we
101-
# do not know, on a variable by that name, is the one that sends less.
107+
# already gives MAPBOX_NO_MODIFY_PATH, so a `0` is someone declining the
108+
# opt-out rather than taking it. Anything else opts out, including a
109+
# spelling nobody planned for: the safe reading of a value we do not know,
110+
# on a variable by that name, is the one that sends less.
102111
$TelemetryAllowed = $true
103-
$disableTelemetry = $env:DISABLE_TELEMETRY
112+
$disableTelemetry = $env:MAPBOX_CLI_NO_TELEMETRY
113+
if ($null -eq $disableTelemetry) {
114+
$disableTelemetry = $env:DISABLE_TELEMETRY
115+
}
104116
if ($null -ne $disableTelemetry) {
105117
$disableTelemetry = $disableTelemetry.Trim().ToLowerInvariant()
106118
$TelemetryAllowed = (

‎scripts/install.sh‎

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,45 @@ USER_AGENT='mapbox-cli-install/1'
6262
# header.
6363
INSTALL_SOURCE="${MAPBOX_CLI_INSTALL_SOURCE:-}"
6464

65-
# The switch `src/http.rs` honours for the CLI's own User-Agent, read here the
66-
# same way, because someone who put DISABLE_TELEMETRY=1 in a Dockerfile and
67-
# then pipes this script into sh in the same file has already said which way
68-
# they want it. The product token above is what survives it — the equivalent of
65+
# The switch `src/telemetry.rs` honours for the CLI's own User-Agent, read here
66+
# the same way, because someone who put it in a Dockerfile and then pipes this
67+
# script into sh in the same file has already said which way they want it. The
68+
# product token above is what survives it — the equivalent of
6969
# `mapbox-cli/<version>` going out either way — and everything appended below
7070
# is what it drops.
7171
#
72+
# **Two names, and only the binary dropped the old one.**
73+
# `MAPBOX_CLI_NO_TELEMETRY` is the documented switch; `DISABLE_TELEMETRY` is
74+
# what it was called before, and this script still honours it. The rename was
75+
# announced as breaking for the binary, so a `DISABLE_TELEMETRY=1` there
76+
# genuinely stopped working and the changelog says so. Nothing announced it for
77+
# the installers — this file is fetched and run in one line, so a reader has no
78+
# release notes in front of them — and breaking an opt-out is the one change
79+
# that must not happen quietly. So both work here, the new name wins when both
80+
# are set, and the old one keeps working for the Dockerfile the comment above
81+
# describes. See mapbox/mapbox-cli-private#140.
82+
#
7283
# Unset, empty, or whitespace: a cleared variable. `0`, `f`, `false`, `n`, `no`
73-
# and `off` are clap's false spellings, so DISABLE_TELEMETRY=0 is someone
74-
# declining the opt-out rather than taking it. Anything else opts out,
75-
# including a spelling nobody planned for: the safe reading of a value we do
76-
# not know, on a variable by that name, is the one that sends less.
84+
# and `off` are clap's false spellings, so a `0` is someone declining the
85+
# opt-out rather than taking it. Anything else opts out, including a spelling
86+
# nobody planned for: the safe reading of a value we do not know, on a variable
87+
# by that name, is the one that sends less.
7788
telemetry_allowed() {
78-
# ASCII-only on purpose, the way `to_ascii_lowercase` is in src/http.rs:
79-
# [:upper:]/[:lower:] would bring the locale into a decision about six
80-
# ASCII spellings, and this script sets no LC_ALL.
89+
# Set at all — even to empty, which is how a shell clears one — means the
90+
# new name is the answer. Otherwise fall back, so the two never have to be
91+
# reconciled: an explicit `MAPBOX_CLI_NO_TELEMETRY=0` beats a stale
92+
# `DISABLE_TELEMETRY=1` left in an image from before the rename.
93+
if [ -n "${MAPBOX_CLI_NO_TELEMETRY+set}" ]; then
94+
_telemetry_switch=$MAPBOX_CLI_NO_TELEMETRY
95+
else
96+
_telemetry_switch=${DISABLE_TELEMETRY-}
97+
fi
98+
99+
# ASCII-only on purpose, the way `to_ascii_lowercase` is in
100+
# src/telemetry.rs: [:upper:]/[:lower:] would bring the locale into a
101+
# decision about six ASCII spellings, and this script sets no LC_ALL.
81102
# shellcheck disable=SC2018,SC2019
82-
case "$(printf '%s' "${DISABLE_TELEMETRY-}" |
103+
case "$(printf '%s' "$_telemetry_switch" |
83104
tr 'A-Z' 'a-z' |
84105
sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" in
85106
'' | 0 | f | false | n | no | off) return 0 ;;

‎scripts/test-install.ps1‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,10 @@ function New-CaseEnv([string]$Name) {
386386
Clear-Env 'MAPBOX_CLI_AUTH'
387387
Clear-Env 'MAPBOX_TILESETS_CLI'
388388
Clear-Env 'MAPBOX_CLI_INSTALL_SOURCE'
389-
# A developer with this set in their own shell would otherwise turn every
390-
# marker case into a failure that looks like the marker broke.
389+
# A developer with either of these set in their own shell would otherwise
390+
# turn every marker case into a failure that looks like the marker broke.
391391
Clear-Env 'DISABLE_TELEMETRY'
392+
Clear-Env 'MAPBOX_CLI_NO_TELEMETRY'
392393
# What install.ps1 reads to decide where it is running. Set explicitly so
393394
# the same case means the same thing on Windows and on the machine this is
394395
# written on.
@@ -513,6 +514,41 @@ try {
513514
Clear-Env 'DISABLE_TELEMETRY'
514515
Clear-Env 'MAPBOX_CLI_INSTALL_SOURCE'
515516

517+
Start-Case 'MAPBOX_CLI_NO_TELEMETRY is honoured, and outranks the old name'
518+
New-CaseEnv 'telemetry-new-name'
519+
$env:MAPBOX_CLI_INSTALL_SOURCE = 'dockerfile'
520+
# The documented name, which the binary reads and this script did not until
521+
# mapbox/mapbox-cli-private#140.
522+
$env:MAPBOX_CLI_NO_TELEMETRY = '1'
523+
[IO.File]::WriteAllText($RequestLog, '')
524+
Invoke-Installer
525+
Expect-Status 0 'exits 0 - the install is not what is being switched off'
526+
$logged = @([IO.File]::ReadAllLines($RequestLog) | Where-Object { $_ })
527+
$bare = @($logged | Where-Object { $_ -like "* $InstallerUa" })
528+
Expect-Equal '2' ([string]$logged.Count) 'still made both requests'
529+
Expect-Equal '2' ([string]$bare.Count) 'each carries the product token and nothing else'
530+
# Both set and disagreeing. The new name is the documented one, so an
531+
# explicit 0 on it beats a DISABLE_TELEMETRY=1 left in an image from before
532+
# the rename - otherwise the old variable could never be retired.
533+
$env:MAPBOX_CLI_NO_TELEMETRY = '0'
534+
$env:DISABLE_TELEMETRY = '1'
535+
[IO.File]::WriteAllText($RequestLog, '')
536+
Invoke-Installer
537+
$logged = @([IO.File]::ReadAllLines($RequestLog) | Where-Object { $_ })
538+
$marked = @($logged | Where-Object { $_ -like "* $InstallerUa ($Target) src/dockerfile" })
539+
Expect-Equal '2' ([string]$marked.Count) 'the new name wins when the two disagree'
540+
# And the other direction, so precedence is pinned rather than implied.
541+
$env:MAPBOX_CLI_NO_TELEMETRY = '1'
542+
$env:DISABLE_TELEMETRY = '0'
543+
[IO.File]::WriteAllText($RequestLog, '')
544+
Invoke-Installer
545+
$logged = @([IO.File]::ReadAllLines($RequestLog) | Where-Object { $_ })
546+
$bare = @($logged | Where-Object { $_ -like "* $InstallerUa" })
547+
Expect-Equal '2' ([string]$bare.Count) 'and wins in the opt-out direction too'
548+
Clear-Env 'MAPBOX_CLI_NO_TELEMETRY'
549+
Clear-Env 'DISABLE_TELEMETRY'
550+
Clear-Env 'MAPBOX_CLI_INSTALL_SOURCE'
551+
516552
Start-Case 'a checksum that does not match installs nothing'
517553
New-CaseEnv 'bad-sha'
518554
$env:MAPBOX_CLI_BASE_URL = "$($open.BaseUrl)/bad-sha-channel"

‎scripts/test-install.sh‎

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ new_case_env() { # case-name
531531
PATH="${CASE_SHIMS}:${SAFE_PATH}"
532532
unset MAPBOX_CLI_VERSION MAPBOX_CLI_AUTH MAPBOX_INSTALL_TILESETS MAPBOX_TILESETS_CLI
533533
unset MAPBOX_CLI_INSTALL_SOURCE
534-
# A developer with this set in their own shell would otherwise turn every
535-
# marker case into a failure that looks like the marker broke.
536-
unset DISABLE_TELEMETRY
534+
# A developer with either of these set in their own shell would otherwise
535+
# turn every marker case into a failure that looks like the marker broke.
536+
unset DISABLE_TELEMETRY MAPBOX_CLI_NO_TELEMETRY
537537
export MAPBOX_CLI_BASE_URL MAPBOX_INSTALL_DIR PATH
538538
}
539539

@@ -658,6 +658,41 @@ expect_in_file "$CURL_LOG" "-A ${INSTALLER_UA} (${TARGET}" 'DISABLE_TELEMETRY=0
658658
expect_in_file "$CURL_LOG" ' src/dockerfile' 'and the tag comes back with it'
659659
unset MAPBOX_TEST_CURL_LOG DISABLE_TELEMETRY MAPBOX_CLI_INSTALL_SOURCE
660660

661+
start 'MAPBOX_CLI_NO_TELEMETRY is honoured, and outranks the old name'
662+
new_case_env telemetry-new-name
663+
export MAPBOX_INSTALL_TILESETS=no
664+
export MAPBOX_CLI_INSTALL_SOURCE=dockerfile
665+
shim curl-recording curl
666+
CURL_LOG="${CASE_DIR}/curl-args"
667+
export MAPBOX_TEST_CURL_LOG="$CURL_LOG"
668+
669+
# The documented name, which the binary reads and this script did not until
670+
# mapbox/mapbox-cli-private#140.
671+
: >"$CURL_LOG"
672+
export MAPBOX_CLI_NO_TELEMETRY=1
673+
run_piped && status=0 || status=$?
674+
expect_status 0 "$status" 'exits 0 — the install is not what is being switched off'
675+
expect_in_file "$CURL_LOG" "-A ${INSTALLER_UA} " 'still names the installer'
676+
expect_not_in_file "$CURL_LOG" "${INSTALLER_UA} (" 'no platform rides behind it'
677+
expect_not_in_file "$CURL_LOG" ' src/' 'and no source tag either'
678+
679+
# Both set, disagreeing. The new name is the documented one, so an explicit
680+
# `0` on it beats a `DISABLE_TELEMETRY=1` left in an image from before the
681+
# rename — otherwise the old variable could never be retired.
682+
: >"$CURL_LOG"
683+
export MAPBOX_CLI_NO_TELEMETRY=0
684+
export DISABLE_TELEMETRY=1
685+
run_piped || true
686+
expect_in_file "$CURL_LOG" "-A ${INSTALLER_UA} (${TARGET}" 'the new name wins when the two disagree'
687+
688+
# And the other direction, so precedence is pinned rather than implied.
689+
: >"$CURL_LOG"
690+
export MAPBOX_CLI_NO_TELEMETRY=1
691+
export DISABLE_TELEMETRY=0
692+
run_piped || true
693+
expect_not_in_file "$CURL_LOG" "${INSTALLER_UA} (" 'and wins in the opt-out direction too'
694+
unset MAPBOX_TEST_CURL_LOG MAPBOX_CLI_NO_TELEMETRY DISABLE_TELEMETRY MAPBOX_CLI_INSTALL_SOURCE
695+
661696
start 'both installers send the same marker'
662697
# The one thing about this marker that cannot be checked by watching a request:
663698
# install.sh and install.ps1 each carry their own copy, because each is served

0 commit comments

Comments
 (0)