Skip to content

Commit 2eb548e

Browse files
alexluongclaude
andcommitted
fix: return 400 for cursor errors in log handlers
Previously, invalid cursor errors would return 500 Internal Server Error. Now properly returns 400 Bad Request for cursor.ErrInvalidCursor and cursor.ErrVersionMismatch, consistent with tenant_handlers.go behavior. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 38c329c commit 2eb548e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/apirouter/log_handlers.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package apirouter
22

33
import (
4+
"errors"
45
"net/http"
56
"strconv"
67
"strings"
78
"time"
89

910
"github.com/gin-gonic/gin"
11+
"github.com/hookdeck/outpost/internal/cursor"
1012
"github.com/hookdeck/outpost/internal/logging"
1113
"github.com/hookdeck/outpost/internal/logstore"
1214
"github.com/hookdeck/outpost/internal/models"
@@ -269,6 +271,10 @@ func (h *LogHandlers) listDeliveriesInternal(c *gin.Context, tenantID string) {
269271

270272
response, err := h.logStore.ListDeliveryEvent(c.Request.Context(), req)
271273
if err != nil {
274+
if errors.Is(err, cursor.ErrInvalidCursor) || errors.Is(err, cursor.ErrVersionMismatch) {
275+
AbortWithError(c, http.StatusBadRequest, NewErrBadRequest(err))
276+
return
277+
}
272278
AbortWithError(c, http.StatusInternalServerError, NewErrInternalServer(err))
273279
return
274280
}
@@ -431,6 +437,10 @@ func (h *LogHandlers) listEventsInternal(c *gin.Context, tenantID string) {
431437

432438
response, err := h.logStore.ListEvent(c.Request.Context(), req)
433439
if err != nil {
440+
if errors.Is(err, cursor.ErrInvalidCursor) || errors.Is(err, cursor.ErrVersionMismatch) {
441+
AbortWithError(c, http.StatusBadRequest, NewErrBadRequest(err))
442+
return
443+
}
434444
AbortWithError(c, http.StatusInternalServerError, NewErrInternalServer(err))
435445
return
436446
}

0 commit comments

Comments
 (0)