Skip to content

Clamp end index for partially filled chunks - #105

Open
dru1x wants to merge 1 commit into
mainfrom
89-requestexceptionhandler-overstates-endindex-for-a-partial-final-batch
Open

Clamp end index for partially filled chunks#105
dru1x wants to merge 1 commit into
mainfrom
89-requestexceptionhandler-overstates-endindex-for-a-partial-final-batch

Conversation

@dru1x

@dru1x dru1x commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

RequestExceptionHandler no longer overstates PushError::endIndex for the final chunk of a batch when the total item count isn't an exact multiple of the batch size.

Changes

  • RequestExceptionHandler now takes a totalCount constructor argument and clamps endIndex to min($startIndex + $batchSize, $totalCount) - 1, instead of always assuming a full-size batch.
  • ExpoPush::makeRequestPool() now accepts and threads through the actual total item count: $pushMessages->notificationCount() for sendNotifications(), $receiptIds->count() for getReceipts().

Testing

Added to tests/Unit/Request/RequestExceptionHandlerTest.php:

  • invoke_clamps_end_index_for_partial_final_batch — constructs the handler with a totalCount that isn't a multiple of batchSize and asserts the reported endIndex matches the actual last item index rather than a full
    batch's worth.

Added to tests/Feature/SendNotificationsTest.php and tests/Feature/GetReceiptsTest.php:

  • send_notifications_reports_correct_end_index_for_partial_final_batch (950 messages, chunks of 100) and get_receipts_reports_correct_end_index_for_partial_final_batch (10,500 receipt IDs, chunks of 1000) — fail the
    final, partial chunk and assert the resulting PushError's startIndex/endIndex stay within the actual input range.

Related Issues

Fixes #89

@dru1x
dru1x requested a review from liamduckett September 6, 2026 20:20
@dru1x dru1x self-assigned this Sep 6, 2026
@dru1x dru1x added the bug Something isn't working label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RequestExceptionHandler overstates endIndex for a partial final batch

1 participant