Skip to content

fix: suppress update notification when --format=json is passed#166

Merged
carlosmonastyrski merged 2 commits into
mainfrom
devin/1774808110-suppress-update-notice-json-format
Mar 29, 2026
Merged

fix: suppress update notification when --format=json is passed#166
carlosmonastyrski merged 2 commits into
mainfrom
devin/1774808110-suppress-update-notice-json-format

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Mar 29, 2026

Description 📣

When using --format=json (e.g., infisical export --format=json) or --output=json (e.g., infisical secrets --output=json), the CLI's "A new release of infisical is available" update notification was printed to stderr, which can break machine-readable output parsing in pipelines that capture both streams.

This adds a check in PersistentPreRun to skip the update notification when the executing subcommand has a --format, --output, or --report-format flag explicitly set to a structured format (json, csv, or yaml).

How it works:

  • New helper isStructuredOutputRequested(cmd) in root.go looks up --format, --output, and --report-format flags on the current command via cobra's Flags().Lookup().
  • Only triggers when the flag is explicitly passed by the user (f.Changed == true), so default values (e.g., --format=dotenv on export) don't suppress the notification.
  • Commands without these flags are unaffected since Lookup returns nil.

Flag coverage:

  • export--format
  • secrets / dynamic_secrets / folder--output
  • scan--report-format (note: defaults to json, but notification is only suppressed when the user explicitly passes the flag)

Type ✨

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

Human Review Checklist 👀

  • Confirm that f.Changed is the right behavior for scan's --report-format (which defaults to json). Currently the update notification still appears for bare infisical scan without an explicit --report-format flag.
  • No unit tests added for the isStructuredOutputRequested helper — acceptable given simplicity, but worth flagging.

Tests 🛠️

Existing update-check tests pass:

go test ./packages/util/ -v -run "TestIsCacheFresh|TestDisplayCached"
# PASS

Full build succeeds:

go build ./...
# ok

Link to Devin session: https://app.devin.ai/sessions/5bb6882c80e042f0a939a3c22602bc79
Requested by: @vmatsiiako

…quested

When --format=json or --output=json (or csv/yaml) is passed, the update
notification message was printed to stderr which could break machine-readable
output parsing. This adds a check in PersistentPreRun to skip the update
notification when a structured output format flag is explicitly set.

Co-Authored-By: Vlad Matsiiako <vm265@cornell.edu>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 29, 2026

Greptile Summary

This PR fixes a UX issue where the "A new release of infisical is available" update notification was being printed to stderr even when a machine-readable output format (json, csv, yaml) was requested, which could break pipelines that capture both stdout and stderr.

The fix introduces a small isStructuredOutputRequested(cmd *cobra.Command) bool helper in root.go that inspects the --format and --output flags on the executing subcommand. By checking f.Changed == true, it correctly avoids suppressing the notification when a structured format is the default (e.g., --format=dotenv on export), only acting when the user explicitly opts into a structured format.

Key observations:

  • The logic is correct and well-scoped for the export (--format) and secrets/dynamic_secrets/folder (--output) commands.
  • The existing --silent persistent flag already provides a broader suppression mechanism; this adds a more targeted, user-friendly path.
  • The scan command uses a different flag name (--report-format, default \"json\") that is not covered by this helper — as the PR checklist acknowledges.
  • No subcommands override PersistentPreRun, so the hook runs consistently for all commands.
  • No new tests were added for the helper (acknowledged by the author); the helper is simple enough that this is acceptable.

Confidence Score: 5/5

Safe to merge — the change is minimal, targeted, and correctly implemented with no risk of regressions.

The only finding is a P2 suggestion about extending coverage to the scan command's --report-format flag, which the PR author already flagged in the checklist. The core logic (using f.Changed to detect explicit user opt-in) is sound, and all existing tests pass.

No files require special attention.

Important Files Changed

Filename Overview
packages/cmd/root.go Adds isStructuredOutputRequested helper and wires it into PersistentPreRun to suppress update notifications when --format or --output is explicitly set to a structured format; logic is correct and uses f.Changed to avoid triggering on default values. Minor gap: scan's --report-format flag is not covered.

Reviews (1): Last reviewed commit: "fix: suppress update notification when s..." | Re-trigger Greptile

Comment thread packages/cmd/root.go
Co-Authored-By: Vlad Matsiiako <vm265@cornell.edu>
@carlosmonastyrski carlosmonastyrski merged commit 97e5070 into main Mar 29, 2026
6 checks passed
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.

2 participants