Skip to content

fix(api): validate test_account_filters on ProjectSerializer too#60636

Merged
sakce merged 1 commit into
masterfrom
posthog-code/validate-test-account-filters-on-project-serializer
May 29, 2026
Merged

fix(api): validate test_account_filters on ProjectSerializer too#60636
sakce merged 1 commit into
masterfrom
posthog-code/validate-test-account-filters-on-project-serializer

Conversation

@sakce
Copy link
Copy Markdown
Contributor

@sakce sakce commented May 29, 2026

Problem

#58129 and #58320 added a pydantic-based validate_test_account_filters to reject non-array writes to Team.test_account_filters, and #58375 backfilled the corrupted rows. But that validator was only wired into TeamSerializer.

ProjectBackwardCompatSerializer — which backs the /api/projects/ endpoint used by the MCP project-settings-update tool — was still missing the same guard, so the field could continue to be corrupted through that path. A customer ticket landed in escalation when an MCP client wrote a JSON-encoded string through the project endpoint.

Changes

Wire the existing validate_test_account_filters into ProjectBackwardCompatSerializer via a @staticmethod that delegates to TeamSerializer.validate_test_account_filters. This matches the pattern already used for validate_modifiers, validate_session_replay_config, validate_session_recording_linked_flag, etc.

No new validation logic — the shared pydantic adapter from posthog/api/team.py is reused, so behavior on /api/projects/ is now identical to /api/environments/.

How did you test this code?

I'm an agent. No new automated test was added — the underlying validator is already covered by test_validate_test_account_filters_rejects_invalid_filters on the team endpoint, and the change is a single delegating staticmethod with no new logic. Verified Python syntax parses.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

🤖 Agent context

Single 3-line staticmethod following the existing "delegate to TeamSerializer" convention. Considered moving the parameterized team-endpoint test into `team_api_test_factory()` so both endpoints would inherit it, but decided that touched more code than the user's "keep changes concise" framing called for — happy to add that on request.


Created with PostHog Code

The TeamSerializer rejects non-array `test_account_filters` writes via
`validate_test_account_filters`, but the ProjectBackwardCompatSerializer
(which backs the `/api/projects/` endpoint used by the MCP
`project-settings-update` tool) was missing the same guard, so the
field could still be corrupted through that path.

Wire the existing validator into ProjectBackwardCompatSerializer via a
staticmethod that delegates to TeamSerializer's, matching the pattern
already used for `validate_modifiers`, `validate_session_replay_config`,
etc. No new validation logic.

Generated-By: PostHog Code
Task-Id: abcd4cd3-e60b-45c9-9672-0f5cd13bce5f
@sakce sakce marked this pull request as ready for review May 29, 2026 10:04
@sakce sakce added the stamphog Request AI review from stamphog label May 29, 2026
@sakce sakce enabled auto-merge (squash) May 29, 2026 10:04
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial one-liner that wires missing validation to the existing TeamSerializer method, consistent with the surrounding delegation pattern. No risk.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 29, 2026

Reviews (1): Last reviewed commit: "fix(api): validate test_account_filters ..." | Re-trigger Greptile

@sakce sakce merged commit 66abf38 into master May 29, 2026
224 checks passed
@sakce sakce deleted the posthog-code/validate-test-account-filters-on-project-serializer branch May 29, 2026 10:21
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented May 29, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-05-29 10:52 UTC Run
prod-us ✅ Deployed 2026-05-29 11:15 UTC Run
prod-eu ✅ Deployed 2026-05-29 11:18 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI review from stamphog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant