Skip to content

Commit

Permalink
Stop retry flow for error handling (conditional trigger) (#12032)
Browse files Browse the repository at this point in the history
* err codes for conditionals

* unit tests for conditional
  • Loading branch information
amirylm authored Feb 16, 2024
1 parent 8ae5f77 commit 30dc562
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ func (s *streams) handleErrCode(result *ocr2keepers.CheckResult, errCode encodin
return nil, err
}
case types.ConditionTrigger:
// switch errCode {
// case encoding.ErrCodePartialContent, encoding.ErrCodeDataStreamsError, encoding.ErrCodeBadRequest, encoding.ErrCodeUnauthorized, encoding.ErrCodeEncodingError:
// default:
// return nil, err // TODO: encomment this line once we have error handler
// }
switch errCode {
case encoding.ErrCodePartialContent, encoding.ErrCodeDataStreamsError, encoding.ErrCodeBadRequest, encoding.ErrCodeUnauthorized, encoding.ErrCodeEncodingError:
default:
return nil, err
}
default:
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ func Test_HandleErrCode(t *testing.T) {
expectedErr error
}{
{
name: "no error",
name: "log trigger no error",
checkResult: &ocr2keepers.CheckResult{
UpkeepID: core.GenUpkeepID(clatypes.LogTrigger, "111"),
},
Expand All @@ -846,7 +846,17 @@ func Test_HandleErrCode(t *testing.T) {
expectedErr: nil,
},
{
name: "error code bad request",
name: "conditional trigger no error",
checkResult: &ocr2keepers.CheckResult{
UpkeepID: core.GenUpkeepID(clatypes.ConditionTrigger, "222"),
},
errCode: encoding.ErrCodeNil,
err: nil,
expectedValues: [][]byte{},
expectedErr: nil,
},
{
name: "log trigger error code bad request",
checkResult: &ocr2keepers.CheckResult{
UpkeepID: core.GenUpkeepID(clatypes.LogTrigger, "111"),
},
Expand All @@ -856,7 +866,17 @@ func Test_HandleErrCode(t *testing.T) {
expectedErr: nil,
},
{
name: "error code partial content with retry timeout",
name: "conditional trigger bad request",
checkResult: &ocr2keepers.CheckResult{
UpkeepID: core.GenUpkeepID(clatypes.ConditionTrigger, "222"),
},
errCode: encoding.ErrCodeBadRequest,
err: errors.New("400"),
expectedValues: [][]byte{},
expectedErr: nil,
},
{
name: "log trigger error code partial content with retry timeout",
checkResult: &ocr2keepers.CheckResult{
UpkeepID: core.GenUpkeepID(clatypes.LogTrigger, "111"),
RetryInterval: mercury.RetryIntervalTimeout,
Expand All @@ -868,7 +888,7 @@ func Test_HandleErrCode(t *testing.T) {
expectedErr: nil,
},
{
name: "error code partial content without retry timeout",
name: "log trigger error code partial content without retry timeout",
checkResult: &ocr2keepers.CheckResult{
UpkeepID: core.GenUpkeepID(clatypes.LogTrigger, "111"),
RetryInterval: time.Second,
Expand All @@ -879,6 +899,18 @@ func Test_HandleErrCode(t *testing.T) {
expectedValues: nil,
expectedErr: partialContentErr,
},
{
name: "conditional trigger partial content",
checkResult: &ocr2keepers.CheckResult{
UpkeepID: core.GenUpkeepID(clatypes.ConditionTrigger, "222"),
RetryInterval: time.Second,
Retryable: true,
},
errCode: encoding.ErrCodePartialContent,
err: errors.New("206"),
expectedValues: [][]byte{},
expectedErr: nil,
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 30dc562

Please sign in to comment.