Skip to content

fix: validate batch size option#175

Merged
marandaneto merged 3 commits into
mainfrom
fix/validate-batch-size
Jun 18, 2026
Merged

fix: validate batch size option#175
marandaneto merged 3 commits into
mainfrom
fix/validate-batch-size

Conversation

@marandaneto

@marandaneto marandaneto commented Jun 17, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

Invalid batch_size values such as 0 or 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-coverage
  • git diff --check
  • ./vendor/bin/phpcs lib/QueueConsumer.php

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to 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_size values still apply, while invalid non-positive values fall back to the existing default. Tests cover default batching, invalid non-positive batch_size fallback behavior, and immediate flushing with batch_size => 1; review feedback was addressed by parameterizing the shared queued-until-flush cases.

@marandaneto marandaneto self-assigned this Jun 17, 2026
@marandaneto marandaneto marked this pull request as ready for review June 17, 2026 16:38
@marandaneto marandaneto requested a review from a team as a code owner June 17, 2026 16:38
@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown
Prompt To Fix All With AI
Fix 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

Comment thread test/PostHogTest.php Outdated
@marandaneto marandaneto merged commit 0de18c8 into main Jun 18, 2026
20 checks passed
@marandaneto marandaneto deleted the fix/validate-batch-size branch June 18, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants