Skip to content

fix: make Feature.type writable on create#6986

Merged
gagantrivedi merged 2 commits intomainfrom
fix/feature-type-writable
Mar 19, 2026
Merged

fix: make Feature.type writable on create#6986
gagantrivedi merged 2 commits intomainfrom
fix/feature-type-writable

Conversation

@gagantrivedi
Copy link
Member

  • I have read the Contributing Guide.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Reverts the type read-only change introduced in #6888.

That PR added type to read_only_fields in CreateFeatureSerializer, which silently discards the type value 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 failing TestAccMultivariateFeatureOptionResource test in Flagsmith/terraform-provider-flagsmith#220.

The model-level choices constraint (also added in #6888) already validates that only STANDARD or MULTIVARIATE are accepted, so removing type from read_only_fields is 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.

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.
@gagantrivedi gagantrivedi requested a review from a team as a code owner March 19, 2026 04:59
@gagantrivedi gagantrivedi requested review from emyller and removed request for a team March 19, 2026 04:59
Copy link

@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

vercel bot commented Mar 19, 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 19, 2026 5:08am
flagsmith-frontend-preview Ignored Ignored Preview Mar 19, 2026 5:08am
flagsmith-frontend-staging Ignored Ignored Preview Mar 19, 2026 5:08am

Request Review

@github-actions github-actions bot added api Issue related to the REST API fix labels Mar 19, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Docker builds report

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

Zaimwa9
Zaimwa9 previously approved these changes Mar 19, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  46.8 seconds
commit  4dc0d87
info  🔄 Run: #15366 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  42.3 seconds
commit  4dc0d87
info  🔄 Run: #15366 (attempt 1)

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

passed  16 passed

Details

stats  16 tests across 13 suites
duration  52.6 seconds
commit  4dc0d87
info  🔄 Run: #15366 (attempt 1)

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

passed  16 passed

Details

stats  16 tests across 13 suites
duration  1 minute, 3 seconds
commit  4dc0d87
info  🔄 Run: #15366 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  9.9 seconds
commit  0ebd98f
info  🔄 Run: #15367 (attempt 1)

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

passed  10 passed

Details

stats  10 tests across 7 suites
duration  30.6 seconds
commit  0ebd98f
info  🔄 Run: #15367 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  60 seconds
commit  0ebd98f
info  🔄 Run: #15367 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  54.9 seconds
commit  0ebd98f
info  🔄 Run: #15367 (attempt 1)

Existing tests were using the deprecated "FLAG" feature type which
is now correctly rejected by the model-level choices constraint.
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.31%. Comparing base (8804097) to head (0ebd98f).
⚠️ Report is 2 commits behind head on main.

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

@gagantrivedi gagantrivedi merged commit 0cb8d90 into main Mar 19, 2026
33 checks passed
@gagantrivedi gagantrivedi deleted the fix/feature-type-writable branch March 19, 2026 05:16
@gagantrivedi gagantrivedi self-assigned this Mar 19, 2026
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 fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants