Repository navigation
Commit aedfc21
authored
fix(cli): exit non-zero when feedback submission is rejected (#1766)
## Bug
`mcpproxy feedback` exits 0 when the submission was not accepted.
`SubmitFeedback` returns `Success: false` without an error in two cases:
the backend answers 2xx with `{"success": false, "error": "..."}`, or it
answers a non-JSON 3xx. `runFeedback` prints "Feedback submission
failed: ..." (in text mode) and then returns `nil`. In `-o json` mode it
prints the JSON and also returns `nil`. Scripts and CI wrappers
therefore treat a rejected submission as sent.
## Trigger
With the telemetry endpoint returning `200
{"success":false,"error":"rejected by backend"}`:
```
$ mcpproxy feedback "the search results could be more relevant" --category bug
Feedback submission failed: rejected by backend
$ echo $?
0
```
## Fix
After rendering the output, return `feedback submission failed: <error>`
when `resp.Success` is false, so the exit code is non-zero in both text
and JSON modes. The text branch no longer prints its own failure line,
because cobra prints the returned error. The success path is unchanged.
## Test
`TestRunFeedback_RejectedSubmissionReturnsError` points the telemetry
endpoint at an `httptest` server that returns `{"success":false}`, and
asserts that `runFeedback` returns an error.
## Commands run
- `go vet ./cmd/mcpproxy`: clean
- `go test -count=1 ./cmd/mcpproxy`: ok (needs cgo; run with `SDKROOT`
set to the macOS 26.5 SDK locally)
- Without the fix, the new test fails with `runFeedback returned nil for
a submission the backend rejected`.
- `gofmt -l` on the edited files: no output1 parent 3b86b9d commit aedfc21
2 files changed
Lines changed: 38 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | 94 | | |
97 | 95 | | |
98 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments