Skip to content

feat: added pagination, transactions and deletion guard#7615

Open
Zaimwa9 wants to merge 3 commits into
mainfrom
feat/experiment-model-robustness
Open

feat: added pagination, transactions and deletion guard#7615
Zaimwa9 wants to merge 3 commits into
mainfrom
feat/experiment-model-robustness

Conversation

@Zaimwa9
Copy link
Copy Markdown
Contributor

@Zaimwa9 Zaimwa9 commented May 27, 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

  • Wrap experiment mutations and status transitions in transaction.atomic, and return 409 (instead of 500) on concurrent-create
    races.
  • Validate ?status= against ExperimentStatus, block DELETE on running experiments, and skip the audit log on no-op PATCH.
  • Paginate the list endpoint with CustomPagination and use _get_environment() per request.
  • Prevent deleting a running experiment

How did you test this code?

  • new tests

@Zaimwa9 Zaimwa9 requested a review from gagantrivedi May 27, 2026 14:34
@Zaimwa9 Zaimwa9 requested a review from a team as a code owner May 27, 2026 14:34
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 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 May 27, 2026 3:35pm
flagsmith-frontend-preview Ignored Ignored Preview May 27, 2026 3:35pm
flagsmith-frontend-staging Ignored Ignored Preview May 27, 2026 3:35pm

Request Review

@github-actions github-actions Bot added api Issue related to the REST API feature New feature or request labels May 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Docker builds report

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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist 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

This pull request introduces pagination, query parameter validation, and transactional safety to the experiment endpoints, alongside preventing the deletion of running experiments and avoiding redundant audit logs. The reviewer identified a critical race condition across several methods where audit logs are created inside transaction.atomic() blocks. This can trigger Celery tasks before the database transaction commits, leading to DoesNotExist errors. To resolve this, the reviewer recommends using transaction.on_commit to defer audit log creation until after successful commits, and also suggests returning early in perform_update when no fields have changed to avoid redundant database writes.

Comment thread api/experimentation/services.py Outdated
Comment thread api/experimentation/views.py Outdated
Comment thread api/experimentation/views.py Outdated
Comment thread api/experimentation/views.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.52%. Comparing base (d118da7) to head (fba6f11).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7615   +/-   ##
=======================================
  Coverage   98.51%   98.52%           
=======================================
  Files        1439     1439           
  Lines       54690    54733   +43     
=======================================
+ Hits        53880    53923   +43     
  Misses        810      810           

☔ 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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

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

passed  12 passed

Details

stats  12 tests across 8 suites
duration  39.3 seconds
commit  4b46cc8
info  🔄 Run: #17034 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  31.7 seconds
commit  4b46cc8
info  🔄 Run: #17034 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  36.7 seconds
commit  4b46cc8
info  🔄 Run: #17034 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  56.4 seconds
commit  4b46cc8
info  🔄 Run: #17034 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  33.3 seconds
commit  4430635
info  🔄 Run: #17036 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  42.8 seconds
commit  4430635
info  🔄 Run: #17036 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  34.3 seconds
commit  4430635
info  🔄 Run: #17036 (attempt 1)

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

passed  2 passed

Details

stats  2 tests across 2 suites
duration  35.9 seconds
commit  4430635
info  🔄 Run: #17036 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.7 seconds
commit  fba6f11
info  🔄 Run: #17041 (attempt 1)

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  31.6 seconds
commit  fba6f11
info  🔄 Run: #17041 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  47.7 seconds
commit  fba6f11
info  🔄 Run: #17041 (attempt 1)

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.6 seconds
commit  fba6f11
info  🔄 Run: #17041 (attempt 1)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Visual Regression

19 screenshots compared. See report for details.
View full report

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels May 27, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels May 27, 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 feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant