Repository navigation
Conversation
The flags service reads a date without a UTC offset and a relative date in the project's timezone. Local evaluation of config version 2 flags read them in UTC, which gives a wrong value in a project on another timezone. The definitions response now carries the project's timezone in a top-level `timezone` field. The client reads it like `property_matching_version`: on load and from the definition cache, into the local evaluation snapshot, and into the definitions fingerprint. The config version 2 evaluator reads naive and relative dates in it. Without the field, or with a name that does not resolve here, the timezone is unknown and a date that needs it is inconclusive, so the flag falls back.
SDK performance: posthog-pythonBenchmarks completed. No changes flagged for review. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
Build the partial-map context from the evaluator replay's `_context` instead of a copy of it, give a case's null timezone to the definitions as it is, and drop the no-tzdata test, which reaches the same branch as an unknown name.
PR overviewNo security issues were found in this pull request. Reviews
|
marandaneto
left a comment
There was a problem hiding this comment.
The code looks good; no qualifying findings. Verdict: correct.
💡 Motivation and Context
The flags service reads a date without a UTC offset (
2024-03-31,2024-03-31 10:00) and a relative date (-30d) in the project's timezone. Local evaluation of config version 2 flags reads them in UTC, so in a project on another timezone a date rule gets a wrong value, not a fallback. In Europe/Oslo,is_date_exact "2024-03-31"matches2024-03-30T23:00:00Zon the server, but not locally.The definitions response gains a top-level
timezonefield: the project's IANA timezone name, next toproperty_matching_version. This PR reads it and passes it to the config version 2 evaluator. When the timezone is unknown, a date that needs it makes the flag fall back instead of being read in UTC. Version 1 flags are unchanged here; the stacked PR handles them.The order is safe either way. The server does not send the field yet, and the definitions request does not ask for config version 2 flags yet (#1314), so nothing changes until both land. This PR should merge before #1314.
Details
timezoneis a non-empty string thatzoneinforesolves. The evaluator reads dates without an offset and relative dates in it.timezoneis absent, null, not a string, empty, or a name this host cannot resolve (for example withouttzdataon Windows). A date predicate that needs the timezone is then inconclusive (missing_context). The flag falls back to/flags, or is unresolved withonly_evaluate_locally=True. Dates with an offset and epoch numbers still decide. An unknown name never fails the load.property_matching_version.FlagDefinitionCacheDatagetstimezone: NotRequired[str], so the public API snapshot gains that one line. The field is left out when the definitions had none. A name this host cannot resolve is kept, because another process that shares the cache may resolve it.💚 How did you test it?
New tests in
posthog/test/test_feature_flags_v2_dispatch.py, plus the corpus replay through the client, which now runs the cases that are set in Europe/Oslo.Details
zoneinforejects. In each form, a flag on a date without an offset falls back with one/flagsrequest, or is unresolved withmissing_contextwhen only evaluating locally. A flag on a date with an offset still decides locally.context.timezoneto the definitions. The 8 Europe/Oslo cases, including relative dates across the DST gap and overlap, now run through the client. 218 cases match exactly; 8 complete-map cases and 43 error cases fall back with their mapped reason.ZoneInfoNotFoundErrorcaught.ruff format --check .,ruff check ., mypy with the baseline,make public_api_check,python -W error -c "import posthog", and the full suite. Only the 3 fork tests intest_metrics_autocapture.pyfail, as they do onmainon macOS.📝 Checklist
If releasing new changes
sampo addto generate a changeset fileA
patchchangeset, as forproperty_matching_version.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
🤖 Generated with Claude Code