Skip to content

Commit 93dc3a3

Browse files
committed
fix: treat 410 Gone as not-found
Hookdeck may return 410 for deleted resources; classify it as not-found to keep deletion UX and tests consistent. Made-with: Cursor
1 parent f9124f0 commit 93dc3a3

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

pkg/gateway/mcp/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TranslateAPIError(err error) string {
2020
switch apiErr.StatusCode {
2121
case http.StatusUnauthorized:
2222
return "Authentication failed. Check your API key."
23-
case http.StatusNotFound:
23+
case http.StatusNotFound, http.StatusGone:
2424
return fmt.Sprintf("Resource not found: %s", apiErr.Message)
2525
case http.StatusUnprocessableEntity:
2626
// Validation errors — pass through the API message directly.

pkg/gateway/mcp/server_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ func TestTranslateAPIError(t *testing.T) {
244244
}{
245245
{"401 Unauthorized", &hookdeck.APIError{StatusCode: 401, Message: "bad key"}, "Authentication failed"},
246246
{"404 Not Found", &hookdeck.APIError{StatusCode: 404, Message: "resource xyz"}, "Resource not found"},
247+
{"410 Gone", &hookdeck.APIError{StatusCode: 410, Message: "resource xyz"}, "Resource not found"},
247248
{"422 Validation", &hookdeck.APIError{StatusCode: 422, Message: "invalid field foo"}, "invalid field foo"},
248249
{"429 Rate Limit", &hookdeck.APIError{StatusCode: 429, Message: "slow down"}, "Rate limited"},
249250
{"500 Server Error", &hookdeck.APIError{StatusCode: 500, Message: "internal"}, "Hookdeck API error"},

pkg/hookdeck/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ func (e *APIError) Error() string {
108108
return fmt.Sprintf("unexpected http status code: %d", e.StatusCode)
109109
}
110110

111-
// IsNotFoundError reports whether the error is an API 404 Not Found response.
111+
// IsNotFoundError reports whether the error is an API "not found" response.
112+
// Hookdeck may return 404 (Not Found) or 410 (Gone) for resources that have
113+
// been deleted.
112114
func IsNotFoundError(err error) bool {
113115
var apiErr *APIError
114-
return errors.As(err, &apiErr) && apiErr.StatusCode == http.StatusNotFound
116+
return errors.As(err, &apiErr) && (apiErr.StatusCode == http.StatusNotFound || apiErr.StatusCode == http.StatusGone)
115117
}
116118

117119
// PerformRequest sends a request to Hookdeck and returns the response.

pkg/hookdeck/client_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import (
1313
"github.com/stretchr/testify/require"
1414
)
1515

16+
func TestIsNotFoundError_410Gone(t *testing.T) {
17+
require.True(t, IsNotFoundError(&APIError{StatusCode: http.StatusGone, Message: "gone"}))
18+
require.False(t, IsNotFoundError(&APIError{StatusCode: http.StatusInternalServerError, Message: "err"}))
19+
}
20+
1621
func TestPerformRequest_ParamsEncoding_Delete(t *testing.T) {
1722
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1823
require.Equal(t, "/delete", r.URL.Path)

0 commit comments

Comments
 (0)