From e69623de04468aeb9f064b68fae7757fe2d2e235 Mon Sep 17 00:00:00 2001 From: Marcin Klocek Date: Mon, 3 Aug 2026 17:44:24 +0200 Subject: [PATCH] Always print html-analysis output as JSON The html-analysis command returns an unstructured JSON payload but printed it using the configured output format. With the default table format and no column definitions, the formatter emitted nothing, so the command appeared to return an empty response. Hardcode JSON output, matching the sibling spam-score command which returns the same kind of payload. Update the html-analysis test to run under the default table format so it guards against this regression, instead of forcing json output which masked the bug. --- internal/commands/messages/html_analysis.go | 3 +-- internal/commands/messages/messages_extended_test.go | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/commands/messages/html_analysis.go b/internal/commands/messages/html_analysis.go index a79e582..3205a39 100644 --- a/internal/commands/messages/html_analysis.go +++ b/internal/commands/messages/html_analysis.go @@ -44,8 +44,7 @@ func NewCmdHTMLAnalysis(f *cmdutil.Factory) *cobra.Command { return err } - format := cmdutil.GetOutputFormat() - return output.Print(f.IOStreams.Out, format, result, nil) + return output.Print(f.IOStreams.Out, output.FormatJSON, result, nil) }, } diff --git a/internal/commands/messages/messages_extended_test.go b/internal/commands/messages/messages_extended_test.go index 8a79a82..9ffc05f 100644 --- a/internal/commands/messages/messages_extended_test.go +++ b/internal/commands/messages/messages_extended_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/mailtrap/mailtrap-cli/internal/commands/messages" - "github.com/spf13/viper" ) func TestMessagesUpdate(t *testing.T) { @@ -152,9 +151,6 @@ func TestMessagesHTMLAnalysis(t *testing.T) { }) defer cleanup() - // html-analysis uses GetOutputFormat, so set output to json to ensure clean output - viper.Set("output", "json") - cmd := messages.NewCmdMessages(f) cmd.SetArgs([]string{"html-analysis", "--sandbox-id", "1", "--id", "1"}) cmd.SetOut(buf)