Skip to content

refactor(api): Replace vendored engine models with flagsmith_schemas TypedDicts - #8606

Draft
khvn26 wants to merge 5 commits into
feat/8597-single-variant-identity-overridesfrom
feat/drop-vendored-engine-models
Draft

khvn26 wants to merge 5 commits into
feat/8597-single-variant-identity-overridesfrom
feat/drop-vendored-engine-models

Conversation

@khvn26

@khvn26 khvn26 commented Sep 25, 2026

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • 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

Contributes to #6654

WIP. In this PR, we replace the vendored Pydantic engine models in util/engine_models with flagsmith_schemas TypedDicts, validated through type adapters.

So far:

  1. Segment membership counts map segments with the evaluation mapper.
  2. Environment and API key documents are built as plain dicts and validated through the flagsmith_schemas Dynamo TypedDicts, replacing the vendored models and the custom document encoder.

Still to do: edge identities, identity override documents, and removing util/engine_models.

The uncompressed environment document no longer carries the always-empty identity_overrides, or entity_selector on non-Dynatrace integrations, as the compressed one already didn't. Every other document, including the SDK environment document, is unchanged.

How did you test this code?

Compared every Dynamo document and the SDK environment document before and after, for an environment with segments, multivariate values, integrations, traits and overrides.

…type adapters

The environment and API key mappers now return plain dicts. Dynamo
documents are validated through the flagsmith_schemas TypedDicts, which
coerce their values, rather than through vendored models and a custom
encoder. The uncompressed environment document no longer carries the
always-empty `identity_overrides`, or `entity_selector` on non-Dynatrace
integrations, as the compressed one already didn't.
@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Sep 26, 2026 8:56pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
flagsmith-frontend-preview Ignored Ignored Preview Sep 26, 2026 8:56pm UTC
flagsmith-frontend-staging Ignored Ignored Preview Sep 26, 2026 8:56pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added api Issue related to the REST API refactor docs Documentation updates labels Sep 25, 2026
@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.16850% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.82%. Comparing base (252e236) to head (84f9bcd).

Files with missing lines Patch % Lines
api/edge_api/identities/serializers.py 93.54% 2 Missing ⚠️
api/edge_api/identities/models.py 98.36% 1 Missing ⚠️
api/edge_api/identities/views.py 94.11% 1 Missing ⚠️
api/util/mappers/engine.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@                              Coverage Diff                              @@
##           feat/8597-single-variant-identity-overrides    #8606    +/-   ##
=============================================================================
  Coverage                                        98.81%   98.82%            
=============================================================================
  Files                                             1645     1630    -15     
  Lines                                            67591    67286   -305     
=============================================================================
- Hits                                             66789    66494   -295     
+ Misses                                             802      792    -10     

☔ 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.

…documents

Edge identities and identity overrides are now plain flagsmith_schemas
TypedDicts, validated through TypeAdapters. Stored numbers are validated
as native numbers, since the schema doesn't round-trip Decimals.
@khvn26
khvn26 force-pushed the feat/drop-vendored-engine-models branch from 07cbca9 to aac37fe Compare September 25, 2026 20:36
@github-actions github-actions Bot added refactor docs Documentation updates and removed docs Documentation updates refactor labels Sep 25, 2026
…anch

Drops the Core-side workaround, now that flagsmith-common keeps stored
Decimals when validating documents.
@khvn26
khvn26 force-pushed the feat/drop-vendored-engine-models branch from d9ec5b7 to 0ac09ae Compare September 26, 2026 20:54
@github-actions github-actions Bot added refactor and removed docs Documentation updates refactor labels Sep 26, 2026

This branch was successfully deployed

1 active deployment
Preview – docs — 84f9bcdd Deployed Sep 26, 2026 by vercel[bot]
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 docs Documentation updates refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant