Skip to content

Conversation

@khvn26
Copy link
Member

@khvn26 khvn26 commented Dec 11, 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

Changes

This change helps us avoid transactions unnecessarily wrapped in transactions that might be the cause of lock contention in prod SaaS.

How did you test this code?

We'll see what CI says, and then test in production.

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

vercel bot commented Dec 11, 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 Dec 11, 2025 4:59pm
flagsmith-frontend-preview Ignored Ignored Dec 11, 2025 4:59pm
flagsmith-frontend-staging Ignored Ignored Dec 11, 2025 4:59pm

@github-actions github-actions bot added api Issue related to the REST API fix labels Dec 11, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Docker builds report

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

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

self.save_without_historical_record()

@transaction.atomic
def clone(self, is_revision: bool = False, **extra_attrs: typing.Any) -> "Segment":
Copy link

Choose a reason for hiding this comment

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

Bug: Clone endpoint fails assertion without transaction wrapper

Removing @transaction.atomic from the clone method breaks the clone endpoint in api/segments/views.py. The clone method calls copy_rules_and_conditions_from, which asserts it must run inside a transaction (assert transaction.get_connection().in_atomic_block). While calls from the serializer and workflow service are wrapped in transactions, the view's clone action at line 140 calls source_segment.clone() directly without any transaction wrapper, causing this call path to fail with an assertion error.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

Good bot, but also bad bot — look out for outer @transaction.atomic usage in the serializers/services that call this method.

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.06%. Comparing base (9e584f1) to head (14c5446).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6399      +/-   ##
==========================================
- Coverage   98.06%   98.06%   -0.01%     
==========================================
  Files        1289     1289              
  Lines       46293    46292       -1     
==========================================
- Hits        45395    45394       -1     
  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.

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