Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consider the case where deliveries can be an empty list #353

Merged
merged 1 commit into from
Dec 30, 2024
Merged
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
6 changes: 6 additions & 0 deletions pkg/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ func (s *Server) handleRetry() http.Handler {
return
}

if len(deliveries) == 0 {
shankiyani marked this conversation as resolved.
Show resolved Hide resolved
logger.InfoContext(ctx, "no deliveries from GitHub",
"cursor", cursor)
break
}

// in anticipation of the happy path, store the first event to advance the
// cursor
if firstCheckpoint == "" {
Expand Down
17 changes: 17 additions & 0 deletions pkg/retry/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ func TestHandleRetry(t *testing.T) {
listDeliveries: &listDeliveriesRes{err: errors.New("error")},
},
},
{
name: "github_list_deliveries_empty",
expStatusCode: http.StatusAccepted,
expRespBody: `{"status":"accepted"}`,
datastoreClientOverride: &MockDatastore{
retrieveCheckpointID: &retrieveCheckpointIDRes{res: "checkpoint-id"},
},
gcsLockClientOverride: &MockLock{
acquire: &acquireRes{},
},
githubOverride: &MockGitHub{
listDeliveries: &listDeliveriesRes{
deliveries: []*github.HookDelivery{},
res: &github.Response{},
},
},
},
{
name: "github_redeliver_event_failure_big_query_entry_not_exists",
expStatusCode: http.StatusInternalServerError,
Expand Down
Loading