Skip to content

fix: validate top-level event uuids#182

Merged
marandaneto merged 2 commits into
mainfrom
fix/validate-event-uuid
Jun 19, 2026
Merged

fix: validate top-level event uuids#182
marandaneto merged 2 commits into
mainfrom
fix/validate-event-uuid

Conversation

@marandaneto

@marandaneto marandaneto commented Jun 19, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

Top-level event uuid values 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-coverage
  • composer api:check
  • php -l lib/Client.php && php -l lib/PostHog.php && php -l test/PostHogTest.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

  • Generated a changeset file

🤖 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 uuid values for capture() and raw() 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.

@marandaneto marandaneto self-assigned this Jun 19, 2026
@greptile-apps

greptile-apps Bot commented Jun 19, 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: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

Comment thread test/PostHogTest.php
Comment thread lib/Client.php
@marandaneto marandaneto marked this pull request as ready for review June 19, 2026 12:32
@marandaneto marandaneto requested a review from a team as a code owner June 19, 2026 12:32
@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown

Reviews (2): Last reviewed commit: "test: parameterize uuid validation cover..." | Re-trigger Greptile

Comment thread lib/Client.php
Comment thread lib/Client.php
@marandaneto marandaneto merged commit 5ed7184 into main Jun 19, 2026
22 checks passed
@marandaneto marandaneto deleted the fix/validate-event-uuid branch June 19, 2026 14:31
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