Skip to content

Make output of bazeldnf more concise upon errors#195

Open
jhorecki-arista wants to merge 1 commit into
rmohr:mainfrom
jhorecki-arista:jhorecki/cleanup-bazeldnf-output
Open

Make output of bazeldnf more concise upon errors#195
jhorecki-arista wants to merge 1 commit into
rmohr:mainfrom
jhorecki-arista:jhorecki/cleanup-bazeldnf-output

Conversation

@jhorecki-arista
Copy link
Copy Markdown

@jhorecki-arista jhorecki-arista commented Apr 1, 2026

Right now when error occurs during the command handling,
the output has the form

<error message>
<bazeldnf help>
<error message repeated>

for example calling bazelisk run :bazeldnf fetch with malformed repo.yaml results in:

Error: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type bazeldnf.Repositories
Usage:
  bazeldnf fetch [flags]

Flags:
  -c, --cache-dir string       Cache directory (default "/Users/jhorecki/Library/Caches/bazeldnf")
  -h, --help                   help for fetch
  -r, --repofile stringArray   repository information file. Can be specified multiple times (default [repo.yaml])

Global Flags:
  -l, --log-level string   log level

error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type bazeldnf.Repositories

the repeated error message makes the output of the tool cluttered. Moreover displaying the help here is misleading as for standard cmd tools it usually suggests malformed arguments given to the command. In practice this leads to misattributing problems when looking at the log.

This PR changes this so when error occurs during cmd parsing, help is displayed as expected but for errors originating from cmd handlers, the output is just the error message. In the example above that would be just

Error: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type bazeldnf.Repositories

Changes output of bazeldnf on error from

<error message>
<bazeldnf help>
<error message repeated>

to
<error message>

when error happens in command handler and not during
argument parsing.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

⚠️ Optional job e2e-bzlmod-toolchain-circular-dependencies failed ⚠️

  • exit status: 1

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