From c7e1e036da14e0486bbc27cd0ae795ad1e983773 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Fri, 23 Oct 2026 23:13:29 -0400 Subject: [PATCH] fix(cli): exit non-zero when feedback submission is rejected --- cmd/mcpproxy/feedback_cmd.go | 5 ++-- cmd/mcpproxy/feedback_cmd_failure_test.go | 35 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 cmd/mcpproxy/feedback_cmd_failure_test.go diff --git a/cmd/mcpproxy/feedback_cmd.go b/cmd/mcpproxy/feedback_cmd.go index d5caca7b4..ba8745e19 100644 --- a/cmd/mcpproxy/feedback_cmd.go +++ b/cmd/mcpproxy/feedback_cmd.go @@ -91,11 +91,12 @@ func runFeedback(cmd *cobra.Command, args []string) error { if resp.IssueURL != "" { fmt.Printf("Track your feedback: %s\n", resp.IssueURL) } - } else { - fmt.Printf("Feedback submission failed: %s\n", resp.Error) } } + if !resp.Success { + return fmt.Errorf("feedback submission failed: %s", resp.Error) + } return nil } diff --git a/cmd/mcpproxy/feedback_cmd_failure_test.go b/cmd/mcpproxy/feedback_cmd_failure_test.go new file mode 100644 index 000000000..d5f76639d --- /dev/null +++ b/cmd/mcpproxy/feedback_cmd_failure_test.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "testing" +) + +// A backend that answers 2xx with {"success":false} rejected the feedback; +// the command must exit non-zero so scripts don't treat it as submitted. +func TestRunFeedback_RejectedSubmissionReturnsError(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"success":false,"error":"rejected by backend"}`)) + })) + defer srv.Close() + + dir := t.TempDir() + cfgPath := filepath.Join(dir, "mcp_config.json") + cfgJSON := fmt.Sprintf(`{"data_dir": %q, "telemetry": {"endpoint": %q}}`, dir, srv.URL) + if err := os.WriteFile(cfgPath, []byte(cfgJSON), 0o600); err != nil { + t.Fatal(err) + } + + origConfig, origCategory := configFile, feedbackCategory + t.Cleanup(func() { configFile, feedbackCategory = origConfig, origCategory }) + configFile, feedbackCategory = cfgPath, "bug" + + if err := runFeedback(nil, []string{"the search results could be more relevant"}); err == nil { + t.Fatal("runFeedback returned nil for a submission the backend rejected") + } +}