fix: validate top-level event uuids#182
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:730-758
**Prefer parameterised tests for invalid-UUID coverage**
The team rule is to always prefer parameterised tests. `testCaptureReplacesInvalidTopLevelUuid` only exercises one invalid value (`"not-a-uuid"`), and `testRawReplacesInvalidTopLevelUuid` only tests `false`. A PHPUnit `@dataProvider` over `capture()` and `raw()` separately would let you cover `null`, `""`, `0`, `false`, `"not-a-uuid"`, and nil UUIDs without repeating the assertion boilerplate, and it makes the intent of each case explicit at a glance. Similarly, `testCaptureKeepsValidTopLevelUuid` only checks one valid value; a data provider covering v1, v4, v7, etc. would confirm the regex boundary correctly.
Reviews (1): Last reviewed commit: "fix: validate top-level event uuids" | Re-trigger Greptile |
marandaneto
commented
Jun 19, 2026
|
Reviews (2): Last reviewed commit: "test: parameterize uuid validation cover..." | Re-trigger Greptile |
ioannisj
approved these changes
Jun 19, 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
Top-level event
uuidvalues can be passed through capture/raw payloads, but invalid values were sent unchanged. This validates supplied UUIDs and replaces invalid values with a generated UUID v4 so queued events keep a valid event identifier.💚 How did you test it?
./vendor/bin/phpunit --no-coverage test/PostHogTest.php --filter 'Uuid|TopLevelUuid'./vendor/bin/phpunit --no-coveragecomposer api:checkphp -l lib/Client.php && php -l lib/PostHog.php && php -l test/PostHogTest.php📝 Checklist
If releasing new changes
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi coding agent implemented the requested UUID validation in a dedicated worktree. The change keeps valid supplied UUIDs, replaces invalid top-level
uuidvalues forcapture()andraw()payloads with generated UUID v4 values, documents the behavior in the PHPDoc, and adds parameterized coverage for valid UUID versions v1-v8 plus invalid fallback cases.