Skip to content

Commit a81ce5b

Browse files
leggetterclaude
andcommitted
fix: report what a request retry actually did, and what a dismiss changed
RetryRequest discarded the response body, so both surfaces reported a fixed outcome. The MCP tool answered {"status":"retried"} and the CLI printed "retry requested" whether the retry created events or matched nothing at all — a retry aimed at a connection the request never went through is accepted and produces nothing, and both said the same thing for it. The client now returns the request and the events created; the MCP tool reports the event ids, and the CLI fails when there are none. The stub for that endpoint returned an empty body, which is not a response the API sends, and the test asserted the hardcoded status — so it passed whether or not a retry had produced anything. Both are corrected. Also makes issue dismissal legible. Two independent QA passes reported "dismiss does not dismiss" after checking status and finding it unchanged. Verified against the API: DELETE returns 200 with dismissed_at populated and status deliberately untouched, because dismissal and resolution are separate axes. Nothing was broken, so nothing is changed except what is said — the CLI now names dismissed_at and states that status is unchanged, and the client records the finding so a third pass does not re-derive it. Switching to PUT {"status":"IGNORED"}, which does change status, would have conflated the two concepts and thrown away the distinction the API draws. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wajsob136PyRh6nc92w5L3
1 parent 7dae336 commit a81ce5b

7 files changed

Lines changed: 84 additions & 14 deletions

File tree

‎pkg/cmd/issue_dismiss.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"time"
78

89
"github.com/spf13/cobra"
910

@@ -75,6 +76,14 @@ func (ic *issueDismissCmd) runIssueDismissCmd(cmd *cobra.Command, args []string)
7576
return nil
7677
}
7778

79+
// Report dismissed_at rather than just the id. Dismissing does not change
80+
// status, so "Issue dismissed" followed by a get still showing OPENED reads
81+
// like a failure; naming the field that did change says what happened.
82+
if iss != nil && iss.DismissedAt != nil {
83+
fmt.Printf(SuccessCheck+" Issue dismissed: %s (dismissed_at %s; status is unchanged at %s)\n",
84+
issueID, iss.DismissedAt.Format(time.RFC3339), iss.Status)
85+
return nil
86+
}
7887
fmt.Printf(SuccessCheck+" Issue dismissed: %s\n", issueID)
7988
return nil
8089
}

‎pkg/cmd/request_retry.go‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,16 @@ func (rc *requestRetryCmd) runRequestRetryCmd(cmd *cobra.Command, args []string)
5353
}
5454
}
5555

56-
if err := client.RetryRequest(ctx, requestID, body); err != nil {
56+
result, err := client.RetryRequest(ctx, requestID, body)
57+
if err != nil {
5758
return fmt.Errorf("failed to retry request: %w", err)
5859
}
59-
fmt.Printf("Request %s retry requested.\n", requestID)
60+
// Say how many events the retry produced. A retry that matches no
61+
// connection is accepted and creates nothing, and "retry requested" reads
62+
// the same for both.
63+
if len(result.Events) == 0 {
64+
return fmt.Errorf("request %s was retried but matched no connection, so no events were created", requestID)
65+
}
66+
fmt.Printf("Request %s retried: %d event(s) created.\n", requestID, len(result.Events))
6067
return nil
6168
}

‎pkg/gateway/mcp/tool_request.go‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,21 @@ func requestRetry(ctx context.Context, client *hookdeck.Client, in mcpcore.Input
157157
if ids := mcpcore.StringList(in, "connection_ids"); len(ids) > 0 {
158158
body = &hookdeck.RequestRetryRequest{WebhookIDs: ids}
159159
}
160-
if err := client.RetryRequest(ctx, id, body); err != nil {
160+
result, err := client.RetryRequest(ctx, id, body)
161+
if err != nil {
161162
return mcpcore.ErrorResult(mcpcore.TranslateAPIError(err)), nil
162163
}
163-
return mcpcore.JSONResultEnvelopeForClient(map[string]string{
164+
// Report the events the retry created rather than a fixed "retried". A
165+
// retry that matches no connection — including one aimed at a connection
166+
// the request never went through — is accepted and creates nothing, and
167+
// saying "retried" for that is a wrong answer that reads like a right one.
168+
eventIDs := make([]string, 0, len(result.Events))
169+
for _, event := range result.Events {
170+
eventIDs = append(eventIDs, event.ID)
171+
}
172+
return mcpcore.JSONResultEnvelopeForClient(map[string]any{
164173
"request_id": id,
165-
"status": "retried",
174+
"events": eventIDs,
175+
"retried": len(eventIDs) > 0,
166176
}, client)
167177
}

‎pkg/gateway/mcp/write_actions_test.go‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,10 +1162,20 @@ func TestRequestEventsAndIgnoredEvents(t *testing.T) {
11621162
}
11631163
}
11641164

1165+
// retriedRequest is what the retry endpoint actually returns: the request and
1166+
// the events the retry created. Stubbing an empty body described a response the
1167+
// API does not send, and hid whether a retry had produced anything.
1168+
func retriedRequest() map[string]any {
1169+
return map[string]any{
1170+
"request": map[string]any{"id": "req_1"},
1171+
"events": []any{map[string]any{"id": "evt_1"}},
1172+
}
1173+
}
1174+
11651175
func TestRequestRetrySendsSelectedConnections(t *testing.T) {
11661176
var got wireRequest
11671177
session := writeSession(t, map[string]http.HandlerFunc{
1168-
"POST /2025-07-01/requests/req_1/retry": ok(&got, nil),
1178+
"POST /2025-07-01/requests/req_1/retry": ok(&got, retriedRequest()),
11691179
})
11701180

11711181
text := succeeds(t, session, "gateway_request", map[string]any{
@@ -1177,15 +1187,18 @@ func TestRequestRetrySendsSelectedConnections(t *testing.T) {
11771187
// connection_ids is the MCP name for the API's webhook_ids; dropping it
11781188
// would retry every connection instead of the two asked for.
11791189
assert.Equal(t, []any{"web_1", "web_2"}, got.decodeBody(t)["webhook_ids"])
1180-
assert.JSONEq(t, `{"request_id":"req_1","status":"retried"}`, string(envelopeData(t, text)))
1190+
// Asserts the events the retry created, not a fixed "retried". The previous
1191+
// version of this line pinned the hardcoded status, so it passed whether or
1192+
// not the retry had produced anything.
1193+
assert.JSONEq(t, `{"request_id":"req_1","events":["evt_1"],"retried":true}`, string(envelopeData(t, text)))
11811194
}
11821195

11831196
// Omitting connection_ids must send an empty body, which the API reads as
11841197
// "every connection the request matched".
11851198
func TestRequestRetryWithoutConnectionsSendsNoIDs(t *testing.T) {
11861199
var got wireRequest
11871200
session := writeSession(t, map[string]http.HandlerFunc{
1188-
"POST /2025-07-01/requests/req_1/retry": ok(&got, nil),
1201+
"POST /2025-07-01/requests/req_1/retry": ok(&got, retriedRequest()),
11891202
})
11901203

11911204
succeeds(t, session, "gateway_request", map[string]any{"action": "retry", "id": "req_1"})

‎pkg/hookdeck/issues.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ func (c *Client) UpdateIssue(ctx context.Context, id string, req *IssueUpdateReq
130130
}
131131

132132
// DismissIssue dismisses an issue (DELETE /issues/{id}).
133+
//
134+
// Dismissing sets dismissed_at and deliberately leaves status alone: an issue
135+
// that is still OPENED after a successful dismiss is correct, because dismissal
136+
// and resolution are separate axes. Verified against the API — DELETE returns
137+
// 200 with dismissed_at populated and status unchanged.
138+
//
139+
// Two independent QA passes have reported this as "dismiss does not dismiss"
140+
// after checking status and not dismissed_at. It is not a defect, and changing
141+
// this to PUT {"status":"IGNORED"} — which does change status — would conflate
142+
// the two concepts and throw away the distinction the API is drawing.
133143
func (c *Client) DismissIssue(ctx context.Context, id string) (*Issue, error) {
134144
path, err := apiPath("issues", id)
135145
if err != nil {

‎pkg/hookdeck/path_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ func byIDCalls() []byIDCall {
219219
return err
220220
}, at("requests", "%s"), false},
221221
{"RetryRequest", func(ctx context.Context, c *Client, id string) error {
222-
return c.RetryRequest(ctx, id, nil)
222+
_, err := c.RetryRequest(ctx, id, nil)
223+
return err
223224
}, at("requests", "%s", "retry"), false},
224225
{"GetRequestEvents", func(ctx context.Context, c *Client, id string) error {
225226
_, err := c.GetRequestEvents(ctx, id, nil)

‎pkg/hookdeck/requests.go‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,45 @@ func (c *Client) GetRequest(ctx context.Context, id string, params map[string]st
8989
return &req, nil
9090
}
9191

92+
// RequestRetryResponse is what a retry returns: the request as it now stands
93+
// and the events the retry created.
94+
//
95+
// Events is the part that matters. A retry that matches no connection is
96+
// accepted and creates nothing, so the caller has to be able to tell those
97+
// apart — reporting "retried" without reading this said the same thing either
98+
// way.
99+
type RequestRetryResponse struct {
100+
Request *Request `json:"request"`
101+
Events []Event `json:"events"`
102+
}
103+
92104
// RetryRequest retries a request by ID. Pass nil or empty WebhookIDs to retry on all connections; otherwise only for the given connection IDs.
93-
func (c *Client) RetryRequest(ctx context.Context, requestID string, body *RequestRetryRequest) error {
105+
func (c *Client) RetryRequest(ctx context.Context, requestID string, body *RequestRetryRequest) (*RequestRetryResponse, error) {
94106
path, err := apiPath("requests", requestID, "retry")
95107
if err != nil {
96-
return err
108+
return nil, err
97109
}
98110
if body == nil {
99111
body = &RequestRetryRequest{}
100112
}
101113
data, err := json.Marshal(body)
102114
if err != nil {
103-
return fmt.Errorf("failed to marshal request retry body: %w", err)
115+
return nil, fmt.Errorf("failed to marshal request retry body: %w", err)
104116
}
105117
resp, err := c.Post(ctx, path, data, nil)
106118
if err != nil {
107-
return err
119+
return nil, err
108120
}
109121
defer resp.Body.Close()
110-
return checkAndPrintError(resp)
122+
if err := checkAndPrintError(resp); err != nil {
123+
return nil, err
124+
}
125+
126+
var out RequestRetryResponse
127+
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
128+
return nil, fmt.Errorf("failed to parse request retry response: %w", err)
129+
}
130+
return &out, nil
111131
}
112132

113133
// GetRequestEvents returns the list of events for a request (GET /requests/{id}/events)

0 commit comments

Comments
 (0)