Skip to content

Commit 8c64d5a

Browse files
committed
jobs: fix off-by-one error in checkStateChangeLog causing slice bounds panic
The calculation len(logs)-i+1 was requesting more logs to be marked unread than actually existed, causing lastReadIdx to go negative and panic on subsequent GetUnreadLogs calls. Release note: None Epic: None
1 parent afdad22 commit 8c64d5a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/jobs/jobs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func (rts *registryTestSuite) checkStateChangeLog(
377377
jobEventsLog.PreviousStatus == string(expectedPrevState) &&
378378
jobEventsLog.NewStatus == string(expectedNewState) &&
379379
strings.Contains(jobEventsLog.Error, expectedError) {
380-
rts.statusChangeLogSpy.SetLastNLogsAsUnread(logpb.Channel_OPS, len(logs)-i+1)
380+
rts.statusChangeLogSpy.SetLastNLogsAsUnread(logpb.Channel_OPS, len(logs)-i)
381381
return nil
382382
}
383383
}

0 commit comments

Comments
 (0)