Skip to content

Commit d31c29b

Browse files
committed
Fix jq error bypass to use resolved format and outWriter
- Re-resolve format via resolveFormat() so --agent --json stays JSON - Use outWriter instead of os.Stdout to respect test mode buffer
1 parent f3d5649 commit d31c29b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

internal/commands/root.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,11 @@ func Execute() {
196196

197197
// jq-related errors (validation failures, unsupported commands, conflicts)
198198
// must never be fed through the jq filter. Rebuild the output writer
199-
// without jq so the error renders cleanly.
199+
// without jq so the error renders cleanly. Re-resolve the format to
200+
// honor explicit flags like --agent --json.
200201
if errors.IsJQError(err) && cfgJQ != "" {
201-
format := output.FormatJSON // --jq implies --json
202-
if cfgAgent || cfgQuiet {
203-
format = output.FormatQuiet
204-
}
205-
out = output.New(output.Options{Format: format, Writer: os.Stdout})
202+
format, _ := resolveFormat()
203+
out = output.New(output.Options{Format: format, Writer: outWriter})
206204
}
207205

208206
_ = out.Err(e)

0 commit comments

Comments
 (0)