Skip to content

fix(cli): honor --telemetry=false opt-out - #421

Open
jackie-greenbaum wants to merge 1 commit into
Infisical:mainfrom
jackie-greenbaum:main
Open

jackie-greenbaum wants to merge 1 commit into
Infisical:mainfrom
jackie-greenbaum:main

Conversation

@jackie-greenbaum

@jackie-greenbaum jackie-greenbaum commented Oct 6, 2026 •

Copy link
Copy Markdown

Description 📣

Telemetry was initialized before Cobra parsed command-line flags, so --telemetry=false incorrectly used the default enabled value.

Move telemetry initialization to a Cobra OnInitialize callback so the explicit opt-out is respected. Telemetry remains enabled by default.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

  • Ran go test ./packages/cmd/... -vet=off -count=2; all tests passed.
    Vet was disabled due to pre-existing nonconstant Msgf format-string
    errors.
  • Added new automated test for opt-out flag
  • Manually tested the patched CLI in a downstream integration and
    confirmed that --telemetry=false is respected.

@infisical-cla-app

infisical-cla-app Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

✅ CLA satisfied. All contributors have signed the current CLA. The cla/signed check is passing.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5 Tier: plus

[Low risk] Moves telemetry initialization to a separate function.

The PR appears safe to merge, with a non-blocking recommendation to add an opt-out regression test.

Findings

  1. P2 Opt-out lacks regression coverage ▶
Summary

Moves telemetry initialization into Cobra's initialization callbacks so --telemetry=false is read after flag parsing.

  • Keeps telemetry enabled by default.
  • Handles errors when reading the flag.
  • Adds no automated regression test for the opt-out; adding one is a non-blocking recommendation.

Reviews (1) · Last reviewed commit: "fix(cli): honor --telemetry=false opt-ou..."

Comment thread packages/cmd/root.go
util.GetStderrWriter = RootCmdStderrWriter
util.GetStdoutWriter = RootCmdStdoutWriter
cobra.OnInitialize(initLog, initLogOutput)
cobra.OnInitialize(initLog, initLogOutput, initTelemetry)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Opt-out lacks regression coverage

The fix has no automated test for the behavior it changes, so a later change could silently break the opt-out again. Add a test that executes a child command through Cobra with --telemetry=false and with no telemetry flag. Calling initTelemetry directly would miss the original flag-parsing bug.

Use a test key or an injected constructor: an empty POSTHOG_API_KEY_FOR_CLI makes NewTelemetry disable telemetry in both cases. This is a non-blocking recommendation.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added automated regression test for the opt-out flag

Telemetry was initialized before Cobra parsed command-line flags,
so --telemetry=false incorrectly used the default enabled value.

Move telemetry initialization to a Cobra OnInitialize callback so
the explicit opt-out is respected. Telemetry remains enabled by default.
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