Verbosity flag provides no extra information (#1501) by ronidelacruz-astro · Pull Request #1968 · astronomer/astro-cli
Description
Fix --verbosity debug flag not working in Homebrew-installed and GitHub release binaries.
The --verbosity flag was not functioning in binaries built with GoReleaser (used for Homebrew and GitHub releases). When users ran commands like astro workspace list --verbosity debug, no debug output was displayed, even though the flag was recognized and validated.
Root Cause: GoReleaser uses the -X linker flag to inject version information at compile time. This interferes with cobra's package-level variable binding mechanism, preventing the verboseLevel variable from receiving the flag value.
Solution: Modified SetupLogging in cmd/root_hooks.go to read the flag value directly from the cobra command object instead of relying on the package-level variable. This bypasses the broken binding and ensures the logger is correctly configured in all build environments.
Impact:
- Fixes verbosity flag for all Homebrew installations
- Fixes verbosity flag for all GitHub release binaries
- Maintains backward compatibility with source builds
- Low risk - defensive change with fallback to original behavior
🎟 Issue(s)
🧪 Functional Testing
A/B Testing with Homebrew Build Flags:
- Built original code with GoReleaser flags:
go build -ldflags="-s -w -X github.com/astronomer/astro-cli/version.CurrVersion=1.37.0"→ No debug output - Built fixed code with same flags → Debug output works correctly
📸 Screenshots
📋 Checklist
- Rebased from the main (or release if patching) branch (before testing)
- Ran
make testbefore taking out of draft - Ran
make lintbefore taking out of draft - Added/updated applicable tests
- Tested against Astro-API (if necessary) - N/A
- Tested against Houston-API and Astronomer (if necessary) - N/A
- Communicated to/tagged owners of respective clients potentially impacted by these changes
- Updated any related documentation - Will update CLI docs if needed