fix: make Feature.type writable on create#6986
Conversation
The type field was made read-only in #6888, which broke API clients that explicitly set type to MULTIVARIATE when creating features. The model-level choices constraint still validates the value.
There was a problem hiding this comment.
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Docker builds report
|
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
|
Existing tests were using the deprecated "FLAG" feature type which is now correctly rejected by the model-level choices constraint.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6986 +/- ##
=======================================
Coverage 98.31% 98.31%
=======================================
Files 1335 1335
Lines 49782 49784 +2
=======================================
+ Hits 48945 48947 +2
Misses 837 837 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Changes
Reverts the
typeread-only change introduced in #6888.That PR added
typetoread_only_fieldsinCreateFeatureSerializer, which silently discards thetypevalue from API requests. This breaks the Terraform provider — when it sends"type": "MULTIVARIATE"to create a feature, the API ignores it and returns"type": "STANDARD", causing Terraform to error with "Provider produced inconsistent result after apply". See the failingTestAccMultivariateFeatureOptionResourcetest in Flagsmith/terraform-provider-flagsmith#220.The model-level
choicesconstraint (also added in #6888) already validates that onlySTANDARDorMULTIVARIATEare accepted, so removingtypefromread_only_fieldsis safe — invalid values like"boolean"or"FLAG"still return a 400.How did you test this code?
Parametrised test covering valid types (
STANDARD→ 201,MULTIVARIATE→ 201) and invalid types ("boolean"→ 400,"FLAG"→ 400). Existing lifecycle hook test for MV options still passes.