fix: validate batch size option#175
Merged
Merged
Conversation
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
test/PostHogTest.php:379-412
**Prefer parameterised tests for related queue-behavior scenarios**
`testLowVolumeCapturesStayQueuedUntilFlush` and `testInvalidBatchSizeUsesDefault` share identical assertion logic (one capture, zero HTTP calls before flush, one `/batch/` call after explicit flush). The only structural difference is the options array. Folding the default-batch-size case into the `invalidBatchSizeCases` provider — or creating a combined provider that also covers the `null`/omitted `batch_size` scenario — would express this as OnceAndOnlyOnce and make any future queue-behavior change a single edit. `testBatchSizeOneFlushesImmediately` tests a meaningfully different observable outcome (auto-flush) and is fine as a standalone, or could itself become a named entry in a provider keyed on `[batch_size, expectsImmediateFlush]`.
Reviews (1): Last reviewed commit: "fix: validate batch size option" | Re-trigger Greptile |
ioannisj
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Invalid
batch_sizevalues such as0or negative numbers could make queued consumers flush with a non-positive batch size. This hardens the option so non-positive values keep the default batch size, while documenting the intended queue behavior with parameterized tests.💚 How did you test it?
./vendor/bin/phpunit --no-coverage test/PostHogTest.php --filter 'CapturesStayQueued|BatchSizeOne'./vendor/bin/phpunit --no-coverage test/PostHogTest.php./vendor/bin/phpunit --no-coveragegit diff --check./vendor/bin/phpcs lib/QueueConsumer.php📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Pi coding agent assistance. The change keeps the queue consumer behavior minimal: valid positive
batch_sizevalues still apply, while invalid non-positive values fall back to the existing default. Tests cover default batching, invalid non-positivebatch_sizefallback behavior, and immediate flushing withbatch_size => 1; review feedback was addressed by parameterizing the shared queued-until-flush cases.