fix(cmd): stop travel subcommands clobbering persistent viper keys#33
Merged
omarshahine merged 1 commit intosteipete:mainfrom Apr 16, 2026
Merged
Conversation
travel.go's init() bound global viper keys (timezone, trip, plan, name, date) to subcommand-local flags. Since viper.BindPFlag replaces prior bindings, this had two effects: - The root --timezone persistent flag was shadowed by travelCreateTripCmd's trip-body timezone flag (which defaults to ""). Callers of `metrics trends --timezone ...`, `sleep day --timezone ...`, etc. got an empty tz and the client fell back to the system zone (or UTC with a warning on hosts without resolvable zoneinfo). The --timezone value passed on the CLI never reached the API. - The trip/plan/name/date keys were each bound multiple times, so `travel plans --trip X` read from whichever flag was bound last. Switch every travel-subcommand-specific flag to cmd.Flags().GetString(), keeping viper only for genuinely global fields (email/password/user_id/ client_id/client_secret/output). Rename the trip-body timezone flag to --trip-timezone so it cannot visually collide with the persistent --timezone flag in the future. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
`internal/cmd/travel.go` bound global viper keys to subcommand-local flags. Because `viper.BindPFlag` replaces prior bindings, several persistent flags were silently shadowed.
Visible symptoms
`--timezone` ignored by metrics/sleep/schedule. The root persistent `--timezone` flag (bound in `root.go`) was re-bound in travel's `init()` to `travelCreateTripCmd`'s trip-body timezone flag — which defaults to `""`. A user running `eightctl metrics trends --timezone America/Los_Angeles` would get an empty tz. The recent tz-resolver then fell back to the system zone (or UTC with a warning when zoneinfo is unresolvable).
`--trip`/`--plan` values leaking across travel subcommands. `trip`, `plan`, `name`, and `date` were each bound multiple times inside travel's `init()`, so only the last binding was live — making several travel subcommands unable to read their own flags.
Fix
Travel-subcommand-specific flags are now read via `cmd.Flags().GetString(...)` from the actual command being run, not through a colliding global viper key. The root persistent flags (`--timezone`, `--email`, `--password`, etc.) are untouched.
The trip-body timezone flag is renamed to `--trip-timezone` so it cannot visually collide with the persistent `--timezone` flag again.
Test plan
Scope
Narrowly the travel init(). No behavior change to any non-travel command other than the CLI flag values now actually reaching them.
🤖 Generated with Claude Code