fix(GODT-2800): Ensure 429 does not cause bad event

This commit is contained in:
Leander Beernaert
2023-07-31 13:15:26 +02:00
parent 06639ff6cd
commit f0e2688a8e
2 changed files with 2 additions and 1 deletions

View File

@ -413,7 +413,7 @@ func (s *Service) handleEventError(ctx context.Context, lastEventID string, even
}
// If the error is a server-side issue, return error to retry later.
if apiErr := new(proton.APIError); errors.As(err, &apiErr) && apiErr.Status >= 500 {
if apiErr := new(proton.APIError); errors.As(err, &apiErr) && (apiErr.Status == 429 || apiErr.Status >= 500) {
return subscriberName, fmt.Errorf("failed to handle event due to server error: %w", err)
}

View File

@ -120,6 +120,7 @@ func TestServiceHandleEventError_NoBadEventCheck(t *testing.T) {
_, _ = service.handleEventError(context.Background(), lastEventID, event, &net.OpError{})
_, _ = service.handleEventError(context.Background(), lastEventID, event, io.ErrUnexpectedEOF)
_, _ = service.handleEventError(context.Background(), lastEventID, event, &proton.APIError{Status: 500})
_, _ = service.handleEventError(context.Background(), lastEventID, event, &proton.APIError{Status: 429})
}
func TestServiceHandleEventError_JsonUnmarshalEventProducesUncategorizedErrorEvent(t *testing.T) {