Skip to content

feat(Dogfooding): Add OpenFeature SDK for server-side Flagsmith-on-Flagsmith#7008

Open
khvn26 wants to merge 2 commits intomainfrom
feat/openfeature-sdk-migration
Open

feat(Dogfooding): Add OpenFeature SDK for server-side Flagsmith-on-Flagsmith#7008
khvn26 wants to merge 2 commits intomainfrom
feat/openfeature-sdk-migration

Conversation

@khvn26
Copy link
Copy Markdown
Member

@khvn26 khvn26 commented Mar 20, 2026

  • 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

Migrate Flagsmith-on-Flagsmith feature evaluation from the native Flagsmith Python SDK to the vendor-neutral OpenFeature SDK with the Flagsmith provider.

Added openfeature-sdk and openfeature-provider-flagsmith (>=0.1.6), now published on PyPI with flagsmith SDK v5 support.

Replaced get_client() with get_openfeature_client() in integrations/flagsmith/client.py, using OpenFeature's provider registry with a named domain (flagsmith-api) and lazy initialisation via ProviderStatus check.

Replaced flagsmith_identifier + flagsmith_on_flagsmith_api_traits on the Organisation model with a single openfeature_evaluation_context property returning an EvaluationContext.

Migrated all call-sites from client.get_identity_flags(...).is_feature_enabled("x") to client.get_boolean_value("x", default_value=False, evaluation_context=...), including leftover flags.is_feature_enabled() references in organisations/tasks.py and organisations/task_helpers.py.

enable_features test fixture now uses OpenFeature's InMemoryProvider instead of mocking Flagsmith internals. 22 org tasks tests migrated from manual get_openfeature_client mocks to the fixture.

Added openfeature_flagsmith.* and licensing.* to mypy ignore_missing_imports overrides (packages lack py.typed).

How did you test this code?

Made sure existing tests pass.

@khvn26 khvn26 requested a review from a team as a code owner March 20, 2026 18:59
@khvn26 khvn26 requested review from gagantrivedi and removed request for a team March 20, 2026 18:59
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.

Once credits are available, reopen this pull request to trigger a review.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 20, 2026

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

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Mar 31, 2026 9:46am
flagsmith-frontend-preview Ignored Ignored Preview Mar 31, 2026 9:46am
flagsmith-frontend-staging Ignored Ignored Preview Mar 31, 2026 9:46am

Request Review

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request labels Mar 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 20, 2026

Docker builds report

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

Comment on lines +1293 to +1294
variants={"enabled": True},
default_variant="enabled",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, this is how to create an enabled by default in-memory flag for OF. No, there is no shorter way to do this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: I got a bit confused it because of enabled. Bit of a detail just for next readings, do you think we could rename it enabled_variant to avoid thinking it's related to the enabled property ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TBH I'm not sure if it's possible to make this code less confusing, I'd just let it be for now.

Comment on lines +97 to +99
[[tool.mypy.overrides]]
module = ["openfeature_flagsmith.*"]
ignore_missing_imports = true
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@khvn26 khvn26 changed the title feat(API): Add OpenFeature SDK for server-side Flagsmith-on-Flagsmith feat: Add OpenFeature SDK for server-side Flagsmith-on-Flagsmith Mar 20, 2026
@khvn26 khvn26 changed the title feat: Add OpenFeature SDK for server-side Flagsmith-on-Flagsmith feat(Dogfooding): Add OpenFeature SDK for server-side Flagsmith-on-Flagsmith Mar 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 20, 2026

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  43 seconds
commit  11c6b4b
info  🔄 Run: #15405 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  29.2 seconds
commit  11c6b4b
info  🔄 Run: #15405 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  46.1 seconds
commit  11c6b4b
info  🔄 Run: #15405 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 12 seconds
commit  11c6b4b
info  🔄 Run: #15405 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  26.1 seconds
commit  0d6327b
info  🔄 Run: #15590 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  47 seconds
commit  0d6327b
info  🔄 Run: #15590 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  53.3 seconds
commit  0d6327b
info  🔄 Run: #15590 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute
commit  0d6327b
info  🔄 Run: #15590 (attempt 1)

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.33%. Comparing base (9f1d4ec) to head (0d6327b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7008      +/-   ##
==========================================
- Coverage   98.33%   98.33%   -0.01%     
==========================================
  Files        1335     1335              
  Lines       49943    49940       -3     
==========================================
- Hits        49113    49110       -3     
  Misses        830      830              

☔ View full report in Codecov by Sentry.
📢 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.

Zaimwa9

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

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

Not much too say, I would approve if it wasn't for the dependency update and merge conflicts to come. Good addition overall

Comment on lines +1293 to +1294
variants={"enabled": True},
default_variant="enabled",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: I got a bit confused it because of enabled. Bit of a detail just for next readings, do you think we could rename it enabled_variant to avoid thinking it's related to the enabled property ?

khvn26 added 2 commits March 31, 2026 10:41
Migrate Flagsmith-on-Flagsmith feature evaluation from the native
Flagsmith Python SDK to the vendor-neutral OpenFeature SDK with the
Flagsmith provider, dogfooding our own OpenFeature integration.
@khvn26 khvn26 force-pushed the feat/openfeature-sdk-migration branch from ddf8c99 to 0d6327b Compare March 31, 2026 09:46
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Mar 31, 2026
@khvn26 khvn26 requested a review from Zaimwa9 March 31, 2026 09:50
) -> OpenFeatureClient:
openfeature_client = openfeature_api.get_client(domain=domain)
if openfeature_client.get_provider_status() != ProviderStatus.READY:
initialise_provider(domain, **(flagsmith_kwargs or get_provider_kwargs()))
Copy link
Copy Markdown
Contributor

@Zaimwa9 Zaimwa9 Mar 31, 2026

Choose a reason for hiding this comment

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

Are we sure about this code? It looks like a ticking bomb. If we pass in an argument, we don't set any other property, not even the api key?

The only other callsite is in this test that only asserts the given parameter (local evaluation)

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.

2 participants