Skip to content

Fix JIRA_DEBUG env var being ignored by most commands - #24

Merged
rethab merged 4 commits into
mainfrom
fix/issue-930
Jul 12, 2026
Merged

Fix JIRA_DEBUG env var being ignored by most commands#24
rethab merged 4 commits into
mainfrom
fix/issue-930

Conversation

@rethab

@rethab rethab commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Addresses ankitpokhrel#930.

jira init reads the debug setting via viper.GetBool("debug"), so JIRA_DEBUG works there. Every other subcommand instead reads debug directly off the pflag object with cmd.Flags().GetBool("debug") or flags.GetBool("debug"), which never consults viper or the env var, only the --debug flag on the command line. As a result JIRA_DEBUG=true jira issue view ... (and the equivalent for every other subcommand) silently did nothing.

This switches all remaining call sites (issue, epic, sprint, board, project, release and serverinfo commands, plus the sprint query params) to viper.GetBool("debug"), mirroring the pattern already used in internal/config/generator.go. Since --debug is already bound via viper.BindPFlag("debug", ...) in internal/cmd/root/root.go, and viper.AutomaticEnv() + SetEnvPrefix("jira") are configured there too, this makes JIRA_DEBUG resolve consistently everywhere while leaving existing --debug flag behavior unchanged.

Also added a test in internal/query/sprint_test.go covering that JIRA_DEBUG is picked up when constructing sprint query params.

rethab added 4 commits July 12, 2026 09:08
Every subcommand except `jira init` read the --debug flag directly
off the pflag object (cmd.Flags().GetBool("debug") /
flags.GetBool("debug")), which only picks up the command-line flag
and never consults viper's env var binding. `jira init` already read
debug via viper.GetBool("debug"), so JIRA_DEBUG worked there but
nowhere else.

Switch all remaining call sites to viper.GetBool("debug"), matching
the pattern in internal/config/generator.go. viper.AutomaticEnv() +
SetEnvPrefix("jira") in root.go makes JIRA_DEBUG resolve correctly,
and the --debug flag continues to take precedence since it's already
bound via viper.BindPFlag("debug", ...) in root.go, so existing
--debug behavior is unchanged.
…iption

Two call sites still read debug off the pflag object, so JIRA_DEBUG was
ignored there. internal/query/issue.go gates the JQL debug print, which
left 'jira issue list' half-debugging: the API client honored the env var
but the JQL line never printed.
@rethab
rethab merged commit 491e7d9 into main Jul 12, 2026
1 check passed
@rethab
rethab deleted the fix/issue-930 branch July 12, 2026 07:24
rethab added a commit that referenced this pull request Aug 5, 2026
Addresses ankitpokhrel#930.

`jira init` reads the debug setting via `viper.GetBool("debug")`, so
`JIRA_DEBUG` works there. Every other subcommand instead reads debug
directly off the pflag object with `cmd.Flags().GetBool("debug")` or
`flags.GetBool("debug")`, which never consults viper or the env var,
only the `--debug` flag on the command line. As a result
`JIRA_DEBUG=true jira issue view ...` (and the equivalent for every
other subcommand) silently did nothing.

This switches all remaining call sites (issue, epic, sprint, board,
project, release and serverinfo commands, plus the sprint query params)
to `viper.GetBool("debug")`, mirroring the pattern already used in
`internal/config/generator.go`. Since `--debug` is already bound via
`viper.BindPFlag("debug", ...)` in `internal/cmd/root/root.go`, and
`viper.AutomaticEnv()` + `SetEnvPrefix("jira")` are configured there
too, this makes `JIRA_DEBUG` resolve consistently everywhere while
leaving existing `--debug` flag behavior unchanged.

Also added a test in `internal/query/sprint_test.go` covering that
`JIRA_DEBUG` is picked up when constructing sprint query params.
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.

1 participant