fix: skip version check for generator commands#9064
Conversation
|
@olblak, PTAL This PR fixes the immediate problem (banner corrupting completion scripts) by skipping the version check for generator commands and adding the --disable-version-check flag. But the root cause from #9028 is still open: logrus.SetOutput(os.Stdout) means the banner goes to stdout, so any command where someone pipes stdout could still get the banner mixed into their output The issue suggested routing the banner to stderr as one of the fixes. I held off on that here to keep the scope small, but happy to include it in this PR if you'd prefer. Otherwise I can open a follow-up. thanks!! |
|
Thanks for the pullrequest, I like the environment variable and flag to totally disable the version checking as it can reduce http queries to updatecli.io I am struggling to test this change manually or other changes. I am curious what you think about my suggestion on #9028 (comment). Regarding moving the message to stderr, I don't know if it's the time to do it as I would like to revamp to UI and move away from logrus completely, but I never took the time |
|
Thanks for the feedback @olblak! Regarding the The tradeoff is that some commands in I'd lean toward As for only checking on Happy to refactor to the |
|
I could manually test it running Where we shouldn't see |
|
After additional testing, your approach is better, as not every subcommand calls the run function |
Signed-off-by: Olblak <me@olblak.com>
…datecli into fix/version-banner-stderr
|
Good catch on |
|
looks like the analyse check hit a gitHub rate limit. mind re-running it when you get a chance @olblak? |
|
all checks passed @olblak. ready for merge whenever you are :) |
|
Thank you for the pullrequest today I learn |
Fix #9028
Summary
The version check in
PersistentPostRunruns for every subcommand, includingcompletion. Sincelogrusoutput goes to stdout, the "new release available" banner gets captured into generated shell completion scripts, producing an invalid file that breaks the user shell on startup.This hits Homebrew users especially hard since completions are generated at install time, so every new shell gets a syntax error.
What changed
--disable-version-checkflag andUPDATECLI_DISABLE_VERSION_CHECKenv var (same pattern as--disable-changelog)completion,__complete,__completeNoDesc,docs,man,jsonschemacmd.Parent()so nested subcommands likecompletion bashare also correctly skippedTest
Note:
bash -nonly catches the issue if a newer version of updatecli is available (which is what triggers the banner). If you are already on the latest version, no banner is emitted so the test passes regardless.Additional Information
Checklist
Tradeoff
logrus.SetOutput(os.Stdout)sending diagnostic output to stdout) is not addressed here. A follow-up could route the banner to stderr as a more general fix.