Skip to content
Open
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
2 changes: 1 addition & 1 deletion pkg/cmd/request_ignored_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (rc *requestIgnoredEventsCmd) runRequestIgnoredEventsCmd(cmd *cobra.Command

color := ansi.Color(os.Stdout)
for _, e := range resp.Models {
fmt.Printf("%s %s %s\n", color.Green(e.ID), e.Status, e.WebhookID)
fmt.Printf("%s %s %s\n", color.Green(e.ID), e.Cause, e.WebhookID)
}
return nil
}
15 changes: 10 additions & 5 deletions pkg/gateway/mcp/tool_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,18 @@ func eventsListing(ctx context.Context, client *hookdeck.Client, in mcpcore.Inpu
return mcpcore.ErrorResult(err.Error()), nil
}

if ignored {
ignoredResult, err := client.GetRequestIgnoredEvents(ctx, requestID, params)
if err != nil {
return mcpcore.ErrorResult(mcpcore.TranslateAPIError(err)), nil
}
return mcpcore.JSONResultEnvelopeForClient(ignoredResult, client)
}

var result *hookdeck.EventListResponse
switch {
case ignored:
result, err = client.GetRequestIgnoredEvents(ctx, requestID, params)
case requestID != "":
if requestID != "" {
result, err = client.GetRequestEvents(ctx, requestID, params)
default:
} else {
result, err = client.ListEvents(ctx, params)
}
if err != nil {
Expand Down
21 changes: 21 additions & 0 deletions pkg/hookdeck/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ type Event struct {
TeamID string `json:"team_id"`
}

// IgnoredEvent is a record from GET /requests/{id}/ignored_events: an event
// Hookdeck decided not to create. It is not an Event: it has no status, source
// or destination, and cause says why it was ignored.
type IgnoredEvent struct {
ID string `json:"id"`
TeamID string `json:"team_id"`
WebhookID string `json:"webhook_id"`
// Cause is e.g. FILTERED, TRANSFORMATION_FAILED or CLI_DISCONNECTED.
Cause string `json:"cause"`
RequestID string `json:"request_id"`
// Meta depends on the cause: an array, an object or null.
Meta interface{} `json:"meta"`
CreatedAt time.Time `json:"created_at"`
}

// IgnoredEventListResponse is the response from listing a request's ignored events
type IgnoredEventListResponse struct {
Models []IgnoredEvent `json:"models"`
Pagination PaginationResponse `json:"pagination"`
}

// EventData is the payload on an event, returned by GET /events with
// include=data and on a single event.
//
Expand Down
54 changes: 54 additions & 0 deletions pkg/hookdeck/ignored_events_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package hookdeck

import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"net/url"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// GET /requests/{id}/ignored_events returns IgnoredEvent records: id, team_id,
// webhook_id, cause, request_id, meta, created_at. They have no status, source
// or destination, and the cause is the only field that says why the event was
// ignored. meta is an array, an object or null depending on the cause.
const ignoredEventsPage = `{"models":[
{"id":"ign_1","team_id":"t","webhook_id":"web_1","cause":"FILTERED","request_id":"req_1","meta":["body"],"created_at":"2026-11-01T10:00:00Z"},
{"id":"ign_2","team_id":"t","webhook_id":"web_1","cause":"TRANSFORMATION_FAILED","request_id":"req_1","meta":{"error":"boom"},"created_at":"2026-11-01T10:00:01Z"},
{"id":"ign_3","team_id":"t","webhook_id":"web_2","cause":"CLI_DISCONNECTED","request_id":"req_1","meta":null,"created_at":"2026-11-01T10:00:02Z"}
],"pagination":{"limit":10}}`

func TestGetRequestIgnoredEventsKeepsCauseAndMeta(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(ignoredEventsPage))
}))
t.Cleanup(srv.Close)
base, err := url.Parse(srv.URL)
require.NoError(t, err)
c := &Client{BaseURL: base}

resp, err := c.GetRequestIgnoredEvents(context.Background(), "req_1", nil)
require.NoError(t, err)
require.Len(t, resp.Models, 3)

assert.Equal(t, "FILTERED", resp.Models[0].Cause)
assert.Equal(t, []any{"body"}, resp.Models[0].Meta)
assert.Equal(t, "TRANSFORMATION_FAILED", resp.Models[1].Cause)
assert.Equal(t, map[string]any{"error": "boom"}, resp.Models[1].Meta)
assert.Equal(t, "CLI_DISCONNECTED", resp.Models[2].Cause)
assert.Nil(t, resp.Models[2].Meta)

// What the CLI and MCP print: cause and meta present, no phantom status.
out, err := json.Marshal(resp.Models[0])
require.NoError(t, err)
var fields map[string]any
require.NoError(t, json.Unmarshal(out, &fields))
assert.Equal(t, "FILTERED", fields["cause"])
assert.Contains(t, fields, "meta")
assert.NotContains(t, fields, "status")
}
4 changes: 2 additions & 2 deletions pkg/hookdeck/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (c *Client) GetRequestEvents(ctx context.Context, requestID string, params
}

// GetRequestIgnoredEvents returns the list of ignored events for a request (GET /requests/{id}/ignored_events)
func (c *Client) GetRequestIgnoredEvents(ctx context.Context, requestID string, params map[string]string) (*EventListResponse, error) {
func (c *Client) GetRequestIgnoredEvents(ctx context.Context, requestID string, params map[string]string) (*IgnoredEventListResponse, error) {
path, err := apiPath("requests", requestID, "ignored_events")
if err != nil {
return nil, err
Expand All @@ -180,7 +180,7 @@ func (c *Client) GetRequestIgnoredEvents(ctx context.Context, requestID string,
if err != nil {
return nil, err
}
var result EventListResponse
var result IgnoredEventListResponse
_, err = postprocessJsonResponse(resp, &result)
if err != nil {
return nil, fmt.Errorf("failed to parse request ignored events response: %w", err)
Expand Down