Skip to content

LaunchDarkly: Replace individual-targeting segment workaround with edge identity overrides #7331

@khvn26

Description

@khvn26

integrations/launch_darkly/services.py:_import_targets creates two things for every LD targets entry: a feature-specific segment override named individual-targeting-variation-<n> (services.py:455-482) and a Postgres identity + per-identity FeatureState override (services.py:484-525). The segment override was a workaround for #3132, which closed April 2024 — every server-side SDK now supports identity overrides in local evaluation. The TODO at line 458 is stale.

The workaround is no longer dead weight; at scale it blocks edge SDK evaluation entirely. One customer this week ended up with a ~9,300-segment project, dominated by these workaround segments, pushing every env document past DynamoDB's 400 KB BatchWriteItem limit.

Why not just delete the workaround

Edge-v2 projects evaluate identity overrides from flagsmith_environments_v2 documents written via EdgeIdentity.save(). The LD importer only writes Postgres identities, so it never populates those items. Today the segment workaround is what makes edge evaluation work at all for LD-imported individual targets. Strip it alone → silent regression.

Scope

  1. Remove the segment workaround. Delete services.py:455-482 and the TODO.

  2. Write identities and overrides to DynamoDB at import time. Reuse existing batched helpers instead of EdgeIdentity.save() per identity:

    • DynamoIdentityWrapper.write_identities(identities) (identity_wrapper.py:49) — already batched.
    • DynamoEnvironmentV2Wrapper.update_identity_overrides(changeset) (environment_wrapper.py:169) — already batched.

    Build the changeset from the per-identity FeatureState rows the importer just created. Mappers already exist.

Testing

  • Import of a flag with targets creates identities in both Postgres and flagsmith_identities (mocked wrapper assertions).
  • Identity override rows appear in the mocked v2 changeset.
  • No individual-targeting-variation-* segments are created.

Why this matters now

Without this, LD-imported projects with substantial individual-target usage hit this edge-evaluation wall at scale.

Not this issue

  • Cleaning up already-affected projects — handled ad-hoc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions