Conversation
vmcp's main.go called viper.GetBool("debug") before cobra parsed CLI
flags, so the --debug flag was effectively a no-op — the logger was
always initialized at INFO regardless of the flag. This also meant
slog.Debug calls in dependent packages (e.g. Cedar's
"Resolved JWT claim keys for Cedar evaluation" log at
pkg/authz/authorizers/cedar/core.go:452) were never visible even with
--debug on the command line.
Move logger initialization into the root command's PersistentPreRunE so
it runs after cobra has parsed flags and viper has the parsed value.
Leave a minimal INFO-level default logger installed in main() so any
error emitted before cobra's Execute runs still produces structured
output. Matches the pattern already used in cmd/thv/app/commands.go.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5008 +/- ##
==========================================
+ Coverage 69.02% 69.05% +0.02%
==========================================
Files 554 554
Lines 73075 73083 +8
==========================================
+ Hits 50443 50470 +27
+ Misses 19620 19603 -17
+ Partials 3012 3010 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JAORMX
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vmcp's--debugCLI flag was effectively a no-op.cmd/vmcp/main.gocalledviper.GetBool("debug")beforeapp.NewRootCmd().ExecuteContext(ctx)ran, so the flag binding — which happens insideNewRootCmd— had not yet been applied. The logger was always initialized at INFO level, andslog.Debugcalls in dependent packages were invisible regardless of whether the flag was passed.PersistentPreRunE, which runs after cobra has parsed flags and populated viper. Keep a minimal INFO-level default logger inmain()so errors emitted before cobra'sExecutestill produce structured output.This matches the pattern already used in
cmd/thv/app/commands.gofor the mainthvCLI — the same bug was fixed there previously.Type of change
Test plan
task lint-fix)vmcp --debug version(DEBUG line present) vsvmcp version(no DEBUG), confirmed the difference.Changes
cmd/vmcp/main.goviper.GetBool("debug")block; install a minimal INFO-level default logger instead.cmd/vmcp/app/commands.goPersistentPreRunEon the root command that reads the parsed--debugflag and reinstalls the logger at the correct level.Does this introduce a user-facing change?
Yes, in the sense that
vmcp --debugnow actually enables debug logging. Previously it was silently ignored.Special notes for reviewers
cmd/thv/app/commands.go.logging.Newis idempotent — calling it twice (once inmain, once inPersistentPreRunE) is safe.Resolved JWT claim keyslog only became visible once this fix was in place).Generated with Claude Code