Skip to content

fix(api): keep the events schema switch when modifiers are cleared - #116672

Draft
pauldambra wants to merge 1 commit into
masterfrom
posthog/keep-events-schema-on-null-modifiers
Draft

pauldambra wants to merge 1 commit into
masterfrom
posthog/keep-events-schema-on-null-modifiers

Conversation

@pauldambra

Copy link
Copy Markdown
Member

Problem

  • A project admin who clears the query modifiers also clears the native events table switch that PostHog staff set for that project.
  • The project then falls back to the global setting or allowlist, and stops reading the table staff chose.
  • The validator already strips useNewEventsSchema from dict updates, but PATCH {"modifiers": null} replaces the whole column.

Changes

  • Clearing modifiers now keeps useNewEventsSchema. All other modifiers still clear.
  • The team and project serializers merge modifiers through one shared helper, merge_modifiers, instead of two copies of the merge.
  • Dict updates behave as before.

How did you test this code?

Test rationale: test_clearing_modifiers_keeps_use_new_events_schema sends a null PATCH through the environments and projects URLs, which use different serializers. Both cases failed before the fix. The existing test_modifiers_use_new_events_schema_is_not_client_writable covers dict updates only.

Release status

  • No feature flag controls this change

Docs update

None. No document under docs/ covers this server-managed key.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code (claude-opus-5-5) in PostHog Desktop

  • Review on #99248 flagged this bug in code that the refactor only moved. This fix lands on master separately, so the refactor stays a pure move.
  • The open PR search found no other fix.
  • Rejected alternative: reject null with a 400. That would break clients that use null to reset their modifiers.
  • Skills: adopting-prs, paul-pair, writing-tests, improving-drf-endpoints, writing-pr-descriptions.

Created with PostHog Desktop

🤖 Generated with Claude Code

A PATCH with modifiers null replaced the whole column, so it also cleared useNewEventsSchema. Staff set that key per project, and clients cannot set it. Both the team and project serializers now merge modifiers through one helper, which keeps that key on a clear.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: db0f77d0-97b2-40c9-ae23-34ebc183c8fe
@pauldambra pauldambra self-assigned this Oct 13, 2026
@trunk-io

trunk-io Bot commented Oct 13, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

@trunk-io

trunk-io Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

This branch has not been deployed

No deployments
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.

1 participant