Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/mcpproxy/feedback_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
35 changes: 35 additions & 0 deletions cmd/mcpproxy/feedback_cmd_failure_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
}
Loading