Skip to content

fix!: fill a request context $set key by key and let the context beat flag-event defaults - #316

Open
eli-r-ph wants to merge 5 commits into
eli/v1-request-context-optionsfrom
eli/v1-request-context-nested-fill
Open

eli-r-ph wants to merge 5 commits into
eli/v1-request-context-optionsfrom
eli/v1-request-context-nested-fill

Conversation

@eli-r-ph

@eli-r-ph eli-r-ph commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #315.

💡 Motivation and Context

A request context $set is a default for every event in the request. Today it is used only when the event has no $set at all, so an event that sets one person property loses every context person property. The other v1 server SDKs fill these properties key by key (posthog-python, posthog-go and posthog-node).

Changes

  • A $set, $set_once, $groups or $group_set from the request context fills in only the keys the event's own value lacks. The event wins for each key it sets, and a non-object value on either side keeps the event's value whole.
  • The same fill applies to exception properties from exception_options and the scoped context.
  • $feature_flag_called events fill the request context before the client's $is_server and $geoip_disable defaults, so the context wins there as on other events. A per-call disable_geoip still wins over the context.
  • Breaking: the request context shipped in 0.28.0 with whole-value fill. The migration guide and a changeset describe the change.

💚 How did you test it?

  • The flag snapshot test now sets $is_server: false in the context and checks the flag event keeps it; it fails with the old order.
  • test_request_context and a new exception_options unit test check a context $set of {plan: free, source: web} under an event $set of {plan: pro} sends {plan: pro, source: web}. Both fail with the old fill.
  • cargo test --all-features (619 passed) and --no-default-features --features error-tracking,tls (480 passed), cargo clippy --tests -- -D warnings (with and without mcp), cargo fmt -- --check, scripts/check-public-api.sh (no API change).

📝 Checklist

  • All commits are signed (see Commit signing)
  • 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

  • Ran sampo add to generate a changeset file

🤖 Generated with Claude Code

@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 28, 2026 22:32
@eli-r-ph eli-r-ph self-assigned this Oct 28, 2026
@eli-r-ph eli-r-ph changed the title fix!: fill a request context $set key by key under the event's own fix!: fill a request context $set key by key and let the context beat flag-event defaults Oct 28, 2026

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks good; no qualifying findings. Verdict: correct.

@eli-r-ph
eli-r-ph force-pushed the eli/v1-request-context-nested-fill branch from 9d529a4 to ce9eb8c Compare October 29, 2026 18:17
eli-r-ph and others added 5 commits October 29, 2026 15:22
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eli-r-ph
eli-r-ph force-pushed the eli/v1-request-context-nested-fill branch from ce9eb8c to b72dec6 Compare October 29, 2026 22:25

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.

2 participants