Skip to content

fix(flags): apply grace period to flag definitions cache verification#60533

Merged
haacked merged 1 commit into
masterfrom
haacked/verify-improvements
Jun 1, 2026
Merged

fix(flags): apply grace period to flag definitions cache verification#60533
haacked merged 1 commit into
masterfrom
haacked/verify-improvements

Conversation

@haacked
Copy link
Copy Markdown
Contributor

@haacked haacked commented May 28, 2026

Problem

The HyperCache verifier compares cached flag definitions against the database and "fixes" any drift it detects. Both FLAG_DEFINITIONS_HYPERCACHE_MANAGEMENT_CONFIG and FLAG_DEFINITIONS_NO_COHORTS_HYPERCACHE_MANAGEMENT_CONFIG were missing get_team_ids_to_skip_fix_fn, so the verifier had no way to know a flag had just been updated and the async cache rebuild was still in flight. The result was a steady stream of phantom drift reports for teams whose caches were already on their way to being refreshed.

The flags cache already has this protection via _get_team_ids_with_recently_updated_flags in flags_cache.py. The two flag-definitions configs just weren't wired to it.

Changes

  • Renames _get_team_ids_with_recently_updated_flags to get_team_ids_with_recently_updated_flags so it can be shared across modules.
  • Passes it as get_team_ids_to_skip_fix_fn on both flag-definitions HyperCache configs in local_evaluation.py.
  • Adds assertions in the existing config tests to verify both configs now have the skip function wired in.

How did you test this code?

Test coverage.

Make _get_team_ids_with_recently_updated_flags public to enable reuse in HyperCache
management config. Add assertions to verify the grace-period skip is correctly
wired into both cache verification configs.
Copilot AI review requested due to automatic review settings May 28, 2026 20:34
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team May 28, 2026 20:34
@posthog-project-board-bot posthog-project-board-bot Bot moved this to In Review in Feature Flags May 28, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Reviews (1): Last reviewed commit: "fix(flags): export grace period team ID ..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces false-positive “drift” reports from the HyperCache verifier by applying the existing flag-update grace period logic to the flag definitions HyperCache configs (with and without cohorts), so recently-updated teams can be skipped while async rebuilds are still in flight.

Changes:

  • Promotes the flags-cache grace-period helper to a shared, non-private function (get_team_ids_with_recently_updated_flags).
  • Wires that helper into both flag-definitions HyperCache management configs via get_team_ids_to_skip_fix_fn.
  • Extends existing local-evaluation config tests to assert the skip function is set for both configs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
products/feature_flags/backend/flags_cache.py Renames the grace-period helper and keeps the flags HyperCache config using it.
products/feature_flags/backend/local_evaluation.py Adds the grace-period skip function to both flag-definitions HyperCache configs.
products/feature_flags/backend/test/test_flags_cache.py Updates tests to use the renamed public helper.
products/feature_flags/backend/test/test_local_evaluation.py Adds assertions that both flag-definitions configs have the skip function wired in.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-project-automation github-project-automation Bot moved this from In Review to Approved in Feature Flags Jun 1, 2026
@haacked haacked merged commit a77afcb into master Jun 1, 2026
226 of 228 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in Feature Flags Jun 1, 2026
@haacked haacked deleted the haacked/verify-improvements branch June 1, 2026 17:32
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented Jun 1, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-06-01 17:59 UTC Run
prod-us ✅ Deployed 2026-06-01 18:21 UTC Run
prod-eu ✅ Deployed 2026-06-01 18:25 UTC Run

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants