fix(api): validate test_account_filters on ProjectSerializer too#60636
Merged
sakce merged 1 commit intoMay 29, 2026
Merged
Conversation
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
Contributor
|
Reviews (1): Last reviewed commit: "fix(api): validate test_account_filters ..." | Re-trigger Greptile |
mayteio
pushed a commit
that referenced
this pull request
May 29, 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.
Problem
#58129 and #58320 added a pydantic-based
validate_test_account_filtersto reject non-array writes toTeam.test_account_filters, and #58375 backfilled the corrupted rows. But that validator was only wired intoTeamSerializer.ProjectBackwardCompatSerializer— which backs the/api/projects/endpoint used by the MCPproject-settings-updatetool — 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_filtersintoProjectBackwardCompatSerializervia a@staticmethodthat delegates toTeamSerializer.validate_test_account_filters. This matches the pattern already used forvalidate_modifiers,validate_session_replay_config,validate_session_recording_linked_flag, etc.No new validation logic — the shared pydantic adapter from
posthog/api/team.pyis 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_filterson the team endpoint, and the change is a single delegating staticmethod with no new logic. Verified Python syntax parses.Automatic notifications
🤖 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