Skip to content

feat(experimentation): whitelist server-side keys for warehouse ingestion#7865

Open
Zaimwa9 wants to merge 4 commits into
mainfrom
feat/support-server-side-keys-in-experimentation
Open

feat(experimentation): whitelist server-side keys for warehouse ingestion#7865
Zaimwa9 wants to merge 4 commits into
mainfrom
feat/support-server-side-keys-in-experimentation

Conversation

@Zaimwa9

@Zaimwa9 Zaimwa9 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

  • Redis ingestion whitelist entries now store the environment's client API key as the value (was empty), enabling the pipeline to canonicalise ser.… keys to the correct environment_key
  • Warehouse connection create/delete syncs all active server-side keys alongside the client key
  • Server-side keys with expires_at get a matching Redis TTL
  • post_save/post_delete signals on EnvironmentAPIKey keep the whitelist in sync on key rotation/deactivation/deletion (scoped to environments with a warehouse connection)
  • Requires a companion pipeline PR (deploy pipeline first) to switch from EXISTS to GET

How did you test this code?

  • Added 25 unit tests in test_ingestion_sync_service.py, test_tasks.py, test_models.py, test_signals.py

Zaimwa9 added 3 commits June 23, 2026 18:55
…tion

Sync an environment's client key and its active server-side keys to the
ingestion whitelist when a warehouse connection is created, and remove them
on delete. Each entry maps to the environment's client API key so the pipeline
can attribute server-side-key events to it; server-side keys carry a Redis TTL
matching their expiry.
Connect EnvironmentAPIKey post_save/post_delete signals so a server-side key's
whitelisting tracks its validity, scoped to environments that have a warehouse
connection.
@Zaimwa9 Zaimwa9 requested review from a team as code owners June 24, 2026 14:50
@Zaimwa9 Zaimwa9 requested review from emyller and gagantrivedi and removed request for a team June 24, 2026 14:50
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jun 24, 2026 3:05pm
flagsmith-frontend-preview Ignored Ignored Preview Jun 24, 2026 3:05pm
flagsmith-frontend-staging Ignored Ignored Preview Jun 24, 2026 3:05pm

Request Review

@Zaimwa9 Zaimwa9 removed the request for review from emyller June 24, 2026 14:51
@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates feature New feature or request and removed docs Documentation updates labels Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-7865 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-7865 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-7865 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-7865 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7865 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7865 Finished ✅ Results

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.60%. Comparing base (929e1df) to head (07e90f4).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7865      +/-   ##
==========================================
+ Coverage   98.59%   98.60%   +0.01%     
==========================================
  Files        1472     1475       +3     
  Lines       57362    57809     +447     
==========================================
+ Hits        56556    57003     +447     
  Misses        806      806              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.7 seconds
commit  07e90f4
info  🔄 Run: #17783 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  36.8 seconds
commit  07e90f4
info  🔄 Run: #17783 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  33.2 seconds
commit  07e90f4
info  🔄 Run: #17783 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  59.5 seconds
commit  07e90f4
info  🔄 Run: #17783 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  35.4 seconds
commit  b348f39
info  🔄 Run: #17785 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.5 seconds
commit  b348f39
info  🔄 Run: #17785 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  32.4 seconds
commit  b348f39
info  🔄 Run: #17785 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  42.6 seconds
commit  b348f39
info  🔄 Run: #17785 (attempt 1)

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
environment_key: str,
expires_at: datetime | None = None,
) -> None:
"""Whitelist ``key`` for warehouse ingestion, mapping it to the canonical

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.

nit: do we need this docstring?

def delete_environment_key_from_ingestion(environment_api_key: str) -> None:
ingestion_sync_service.delete_environment_key(environment_api_key)
def remove_server_side_key_from_ingestion(key: str) -> None:
"""Remove a deleted server-side key from the ingestion whitelist."""

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.

are we overdoing with the docstring?

@@ -0,0 +1,32 @@
from typing import Any

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.

We're using hooks on the warehouse connection model but a signal here? Is there a reason we can't use hooks here too? Better to stick with one

@register_task_handler()
def add_environment_key_to_ingestion(environment_api_key: str) -> None:
ingestion_sync_service.set_environment_key(environment_api_key)
def sync_environment_ingestion_keys(environment_id: int) -> None:

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.

nit: sync implies that this is handling delete as well?
maybe this can just be write_environment_ingestion_keys considering we also have remove_environment_ingestion_keys



@register_task_handler()
def reconcile_server_side_key_ingestion(environment_api_key_id: int) -> None:

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.

This method name doesnt make much sense to me? This looks like just a singlular form of the above methods?
write_environment_ingestion_key ?

@register_task_handler()
def delete_environment_key_from_ingestion(environment_api_key: str) -> None:
ingestion_sync_service.delete_environment_key(environment_api_key)
def remove_server_side_key_from_ingestion(key: str) -> None:

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.

Suggested change
def remove_server_side_key_from_ingestion(key: str) -> None:
def remove_environment_ingestion_key(key: str) -> None:

instance: EnvironmentAPIKey,
**kwargs: Any,
) -> None:
reconcile_server_side_key_ingestion.delay(

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.

we also need to make sure we only trigger these if wearehouse connection is live

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

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants