fix: suppress update notification when --format=json is passed#166
Conversation
…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 EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis 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 ( The fix introduces a small Key observations:
Confidence Score: 5/5Safe 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 No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix: suppress update notification when s..." | Re-trigger Greptile |
Co-Authored-By: Vlad Matsiiako <vm265@cornell.edu>
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
PersistentPreRunto skip the update notification when the executing subcommand has a--format,--output, or--report-formatflag explicitly set to a structured format (json,csv, oryaml).How it works:
isStructuredOutputRequested(cmd)inroot.golooks up--format,--output, and--report-formatflags on the current command via cobra'sFlags().Lookup().f.Changed == true), so default values (e.g.,--format=dotenvonexport) don't suppress the notification.Lookupreturnsnil.Flag coverage:
export→--formatsecrets/dynamic_secrets/folder→--outputscan→--report-format(note: defaults tojson, but notification is only suppressed when the user explicitly passes the flag)Type ✨
Human Review Checklist 👀
f.Changedis the right behavior forscan's--report-format(which defaults tojson). Currently the update notification still appears for bareinfisical scanwithout an explicit--report-formatflag.isStructuredOutputRequestedhelper — acceptable given simplicity, but worth flagging.Tests 🛠️
Existing update-check tests pass:
Full build succeeds:
go build ./... # okLink to Devin session: https://app.devin.ai/sessions/5bb6882c80e042f0a939a3c22602bc79
Requested by: @vmatsiiako