Skip to content

Conversation

@khvn26
Copy link
Member

@khvn26 khvn26 commented Feb 2, 2026

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 #6050, #5790.

In this PR, we fix incorrect webhook payloads when updating segment overrides (#6050). The root cause was that drf-writable-nested saves FeatureState before FeatureStateValue, so webhooks triggered on post_save captured stale values.

This is a step toward #5790 (centralising webhook logic), but further work remains. The webhook infrastructure still has multiple layers (webhooks/webhooks.py, features/tasks.py, audit/signals.py) that could be unified into a single, consistent system.

  • Remove the post_save signal handler from FeatureState that triggered webhooks prematurely
  • Dispatch FLAG_UPDATED webhooks via the feature_state_change_went_live signal, which fires after AuditLog creation when all nested objects are saved
  • Handle both FeatureState and FeatureStateValue audit logs, since value-only changes also need to trigger webhooks
  • Refactor signal semantics: FeatureState is now the sender (matching the signal name), with AuditLog as a supplemental kwarg

How did you test this code?

Added an integration test reproducing #6050, and various unit tests supporting the fix.

@khvn26 khvn26 requested a review from a team as a code owner February 2, 2026 17:53
@khvn26 khvn26 requested review from gagantrivedi and removed request for a team February 2, 2026 17:53
@vercel
Copy link

vercel bot commented Feb 2, 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 Feb 3, 2026 1:41pm
flagsmith-frontend-preview Ignored Ignored Preview Feb 3, 2026 1:41pm
flagsmith-frontend-staging Ignored Ignored Preview Feb 3, 2026 1:41pm

Request Review

@github-actions github-actions bot added the api Issue related to the REST API label Feb 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Docker builds report

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

@github-actions github-actions bot added the fix label Feb 2, 2026
@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.20%. Comparing base (cdd3386) to head (a1d423f).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6646      +/-   ##
==========================================
+ Coverage   98.18%   98.20%   +0.01%     
==========================================
  Files        1294     1298       +4     
  Lines       46994    47108     +114     
==========================================
+ Hits        46141    46262     +121     
+ Misses        853      846       -7     

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

@github-actions github-actions bot added fix and removed fix labels Feb 2, 2026
Copy link
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid! I have comments about the implementation, and non-blocking suggestions in tests.

@khvn26 khvn26 requested a review from emyller February 3, 2026 12:06
@github-actions github-actions bot added fix and removed fix labels Feb 3, 2026
@github-actions github-actions bot added fix and removed fix labels Feb 3, 2026
Copy link
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@khvn26 khvn26 merged commit 196ebf3 into main Feb 3, 2026
31 checks passed
@khvn26 khvn26 deleted the fix/invalid-env-webhook-values branch February 3, 2026 14:29
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.

3 participants