Skip to content

segment_priority assigned incorrectly when creating flagsmith_feature_state alongside existing overrides #231

Description

@deepforest

flagsmith/flagsmith provider version 0.9.1

Description

When creating a flagsmith_feature_state segment override with segment_priority=0,
the API ignores the requested value and auto-assigns a priority based on existing
overrides in the environment. If another override already holds priority 0,
the new one gets priority 1 regardless of what was requested.

This causes Terraform to fail with:

Provider produced inconsistent result after apply
.segment_priority: was cty.NumberIntVal(0), but now cty.NumberIntVal(1).

Steps to Reproduce

  1. Have a feature with two segment overrides (override_0 priority 0, override_1 priority 1)
  2. Trigger a destroy+create on override_0 (e.g. via replace_triggered_by)
  3. override_1 remains in the API with priority 0 during the recreate
  4. Terraform creates override_0 with segment_priority=0 - API returns 1
  5. Terraform errors: provider produced inconsistent result

Expected Behavior

The API should honor the segment_priority value provided on creation, or the provider
should handle priority conflicts gracefully (e.g. by reordering after creation).

Actual Behavior

The API auto-assigns segment_priority based on insertion order, ignoring the
requested value. The provider does not reconcile this mismatch.

Provider Version

flagsmith/flagsmith v0.9.1

Workaround

Pre-delete all segment overrides for the affected feature before applying, so
Terraform recreates them on a clean slate in the correct order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions