Skip to content

Conversation

@Zaimwa9
Copy link
Contributor

@Zaimwa9 Zaimwa9 commented Dec 3, 2025

Thanks for submitting a PR! Please check the boxes below:

  • 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?
  • I have used a Conventional Commit title for this Pull Request

Closes #6248

Context

Edge-case that is a combination between data corruption when migrating to feature versioning and trying to delete a project.
When migrating, feature states from committed CR where linked to EFV with:

  • A change_request_id
  • live_from = None
    When deleting the project, the soft-delete was triggering the hook here without live_from which raised the NoneType error

Changes

  • Updated hook AFTER_SAVE to ignore CR with deleted_at

How did you test this code?

  • Added a test (fails without change)
  • Manually
  1. Create a new project (feature_versioning_v2 disabled)
  2. Create and publish a change request now (it must have existing CR)
  3. Create a change request in the future
  4. Publish it
  5. Enable feature_versioning_v2
  6. Delete the project

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner December 3, 2025 16:53
@Zaimwa9 Zaimwa9 requested review from khvn26 and removed request for a team December 3, 2025 16:53
@vercel
Copy link

vercel bot commented Dec 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs Ignored Ignored Preview Dec 4, 2025 5:19pm
flagsmith-frontend-preview Ignored Ignored Preview Dec 4, 2025 5:19pm
flagsmith-frontend-staging Ignored Ignored Preview Dec 4, 2025 5:19pm

@Zaimwa9 Zaimwa9 requested a review from matthewelwell December 3, 2025 16:53
@github-actions github-actions bot added the api Issue related to the REST API label Dec 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Docker builds report

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

@github-actions github-actions bot added the fix label Dec 3, 2025
@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.02%. Comparing base (ab32904) to head (05ef502).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6367   +/-   ##
=======================================
  Coverage   98.02%   98.02%           
=======================================
  Files        1282     1282           
  Lines       45498    45513   +15     
=======================================
+ Hits        44600    44615   +15     
  Misses        898      898           

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

latest_feature_states.update(environment_feature_version=ef_version)
latest_feature_states.update(
environment_feature_version=ef_version,
change_request=None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is the less risky place to fix this issue.

I preferred not to add a guard against live_from = None because for any similar bug it would have entered the wrong branch and create an irrelevant log create_feature_state_updated_by_change_request_audit_log

@github-actions github-actions bot added fix and removed fix labels Dec 4, 2025
Zaimwa9 and others added 3 commits December 4, 2025 18:14
…on' of github.com:Flagsmith/flagsmith into fix/enabling-v2-versioning-with-cr-block-project-deletion
@github-actions github-actions bot added fix and removed fix labels Dec 4, 2025
…on' of github.com:Flagsmith/flagsmith into fix/enabling-v2-versioning-with-cr-block-project-deletion
@github-actions github-actions bot added fix and removed fix labels Dec 4, 2025
@Zaimwa9 Zaimwa9 changed the title fix: clear-change-requests-from-features-states-when-enabling-v2-versioning fix: skip-audit-log-for-soft-deleted-CR Dec 5, 2025
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.

Fix missing live_from when creating audit log

2 participants