Skip to content

Conversation

@ronidelacruz-astro
Copy link
Contributor

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)

Closes #1501 #1690

🧪 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 test before taking out of draft
  • Ran make lint before 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

@coveralls-official
Copy link

coveralls-official bot commented Oct 22, 2025

Pull Request Test Coverage Report for Build 3594e26d-8682-4297-8627-84e8d776b975

Details

  • 15 of 20 (75.0%) changed or added relevant lines in 3 files are covered.
  • 46 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 38.52%

Changes Missing Coverage Covered Lines Changed/Added Lines %
software/workspace/workspace.go 4 5 80.0%
cloud/workspace/workspace.go 3 5 60.0%
cmd/root_hooks.go 8 10 80.0%
Files with Coverage Reduction New Missed Lines %
docker/docker.go 2 46.81%
airflow/docker_image.go 44 79.48%
Totals Coverage Status
Change from base Build b5ee00e2-48df-4673-8d27-6c8383bedbad: 0.01%
Covered Lines: 24148
Relevant Lines: 62689

💛 - Coveralls

Copy link
Contributor

@neel-astro neel-astro left a comment

Choose a reason for hiding this comment

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

I believe the problem isn't that the verbosity flag is not set up correctly with those issues, but rather, we do not have any debug logs added for these commands.

@ronidelacruz-astro
Copy link
Contributor Author

I believe the problem isn't that the verbosity flag is not set up correctly with those issues, but rather, we do not have any debug logs added for these commands.

You're right that we need more debug logs, but there was also a real bug: the logger wasn't being set to debug level at all in Homebrew builds due to GoReleaser's -X flag breaking the variable binding. I'll add more debug log statements to the affected commands.

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.

Verbosity flag provides no extra information

3 participants