Skip to content

Commit 2dc6175

Browse files
[wrangler] Expand telemetry arg allow list to restore dropped boolean flags (#13576)
Co-authored-by: ask-bonk[bot] <249159057+ask-bonk[bot]@users.noreply.github.com>
1 parent 21b87b2 commit 2dc6175

3 files changed

Lines changed: 84 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Restore telemetry tracking for common CLI flags that were unintentionally dropped during sanitisation
6+
7+
When argument sanitisation was introduced, only explicitly allow-listed args had their values included in telemetry. The allow list was very conservative, which meant common boolean flags like `--remote`, `--json`, `--dry-run`, `--force`, and many others were no longer being captured in `sanitizedArgs` despite previously being tracked. Boolean flags are inherently safe (values are only `true`/`false`), so these have now been added back to the global allow list. A small number of fixed-choice args (`--local-protocol`, `--upstream-protocol`, `--containers-rollout`) have also been added with their known value sets.

packages/wrangler/src/__tests__/metrics/sanitization.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, it } from "vitest";
22
import {
33
ALLOW,
4+
COMMAND_ARG_ALLOW_LIST,
45
getAllowedArgs,
56
REDACT,
67
sanitizeArgKeys,
@@ -134,3 +135,37 @@ describe("getAllowedArgs", () => {
134135
expect(r2Result.global).toBe(ALLOW);
135136
});
136137
});
138+
139+
describe("COMMAND_ARG_ALLOW_LIST", () => {
140+
it("should pass boolean flag values through the full sanitisation pipeline for any command", ({
141+
expect,
142+
}) => {
143+
// Simulate a user running: wrangler <command> --remote --dry-run --json
144+
const args = {
145+
remote: true,
146+
"dry-run": true,
147+
dryRun: true,
148+
json: true,
149+
$0: "wrangler",
150+
_: [],
151+
};
152+
const argv = [
153+
"node",
154+
"wrangler",
155+
"some-command",
156+
"--remote",
157+
"--dry-run",
158+
"--json",
159+
];
160+
161+
const argsWithSanitizedKeys = sanitizeArgKeys(args, argv);
162+
const allowedArgs = getAllowedArgs(COMMAND_ARG_ALLOW_LIST, "some-command");
163+
const sanitizedArgs = sanitizeArgValues(argsWithSanitizedKeys, allowedArgs);
164+
165+
expect(sanitizedArgs).toEqual({
166+
remote: true,
167+
dryRun: true,
168+
json: true,
169+
});
170+
});
171+
});

packages/wrangler/src/metrics/sanitization.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,57 @@ export type AllowList = Record<string, AllowedArgs>;
4848
* - ALLOW: all values for that arg are allowed
4949
*/
5050
export const COMMAND_ARG_ALLOW_LIST: AllowList = {
51-
// * applies to all commands
51+
// * applies to all commands.
52+
// Boolean flags are inherently safe (values are only true/false).
5253
"*": {
5354
format: ALLOW,
5455
logLevel: ALLOW,
56+
json: ALLOW,
57+
force: ALLOW,
58+
remote: ALLOW,
59+
local: ALLOW,
60+
dryRun: ALLOW,
61+
preview: ALLOW,
62+
yes: ALLOW,
63+
skipConfirmation: ALLOW,
64+
noBundle: ALLOW,
65+
bundle: ALLOW,
66+
minify: ALLOW,
67+
latest: ALLOW,
68+
uploadSourceMaps: ALLOW,
69+
legacyEnv: ALLOW,
70+
liveReload: ALLOW,
71+
keepVars: ALLOW,
72+
logpush: ALLOW,
73+
strict: ALLOW,
74+
testScheduled: ALLOW,
75+
showInteractiveDevSession: ALLOW,
76+
skipCaching: ALLOW,
77+
commitDirty: ALLOW,
78+
includeRuntime: ALLOW,
79+
includeEnv: ALLOW,
80+
strictVars: ALLOW,
81+
check: ALLOW,
82+
useRemote: ALLOW,
83+
updateConfig: ALLOW,
84+
nodeCompat: ALLOW,
85+
enableContainers: ALLOW,
86+
xAutoconfig: ALLOW,
87+
ignoreDefaults: ALLOW,
5588
},
5689
tail: { status: ALLOW },
5790
types: {
5891
xIncludeRuntime: [".wrangler/types/runtime.d.ts"],
5992
path: ["worker-configuration.d.ts"],
6093
},
94+
// Fixed-choice args scoped to their commands.
95+
dev: {
96+
localProtocol: ["http", "https"],
97+
upstreamProtocol: ["http", "https"],
98+
},
99+
deploy: {
100+
containersRollout: ["immediate", "gradual"],
101+
},
61102
};
62103

63104
/**

0 commit comments

Comments
 (0)