Skip to content

fix: Enhance EFV audit logs#7535

Open
SahilJat wants to merge 3 commits into
Flagsmith:mainfrom
SahilJat:feat/enhanced-audit-logs
Open

fix: Enhance EFV audit logs#7535
SahilJat wants to merge 3 commits into
Flagsmith:mainfrom
SahilJat:feat/enhanced-audit-logs

Conversation

@SahilJat
Copy link
Copy Markdown
Contributor

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

Closes #7526

This PR resolves the issue of opaque audit logs for v2 versioning (EnvironmentFeatureVersion). Previously, publishing a new version only logged a static string ("New version published for feature: %s"), completely omitting which feature states were actually changed.

This updates create_environment_feature_version_published_audit_log_task to:

  • Render the EFV message via get_updated_feature_states_for_version(efv).
  • Enumerate each changed Feature State's action (enabled/disabled) and scope (Environment default, Segment override, Identity override).
  • Mitigate N+1 database queries by prefetching feature_segment__segment and identity via select_related.

How did you test this code?

-I wrote comprehensive unit tests in api/tests/unit/audit/test_unit_audit_services.py to cover the different scenarios for the audit log task:

  • Verified that if there are no changes, the audit log falls back to the original header-only format.
  • Verified that modifications to the Environment Default are properly appended to the log string.
  • Verified that modifications to a Segment Override append the specific Segment's name to the log string.

@SahilJat SahilJat requested a review from a team as a code owner May 19, 2026 06:09
@SahilJat SahilJat requested review from khvn26 and removed request for a team May 19, 2026 06:09
Copy link
Copy Markdown

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

@SahilJat is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the api Issue related to the REST API label May 19, 2026
@SahilJat SahilJat changed the title Enhance EFV audit logs fix: Enhance EFV audit logs May 19, 2026
@SahilJat SahilJat force-pushed the feat/enhanced-audit-logs branch from a776a6c to 5aecaf8 Compare May 19, 2026 06:25
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.31%. Comparing base (82c5dfb) to head (3eb06b6).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7535      +/-   ##
==========================================
- Coverage   98.47%   98.31%   -0.16%     
==========================================
  Files        1400     1400              
  Lines       53036    52960      -76     
==========================================
- Hits        52226    52068     -158     
- Misses        810      892      +82     

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

@SahilJat SahilJat force-pushed the feat/enhanced-audit-logs branch from 5aecaf8 to 3eb06b6 Compare May 19, 2026 09:43
@SahilJat
Copy link
Copy Markdown
Contributor Author

@khvn26 the test cases that is failing is already existing issue which will be solved with pr #7530 . This issue is also solved please have a look at it. Thanks

@SahilJat SahilJat closed this May 19, 2026
@SahilJat SahilJat reopened this May 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit: enrich EnvironmentFeatureVersion-published log with changed feature states

1 participant