René's URL Explorer Experiment


Title: fix(billing): close TOCTOU race in subscription transfer, centralize stripe test mocks by waleedlatif1 · Pull Request #4239 · simstudioai/sim · GitHub

Open Graph Title: fix(billing): close TOCTOU race in subscription transfer, centralize stripe test mocks by waleedlatif1 · Pull Request #4239 · simstudioai/sim

X Title: fix(billing): close TOCTOU race in subscription transfer, centralize stripe test mocks by waleedlatif1 · Pull Request #4239 · simstudioai/sim

Description: Summary Wrap subscription-transfer check + update in db.transaction with .for('update') row-locks in both app/api/users/me/subscription/[id]/transfer/route.ts and lib/billing/organization.ts to close a TOCTOU race that allowed concurrent requests to attach two subscriptions to the same org Add .for('update') terminal to dbChainMock and document it in sim-testing.md Add centralized stripe.mock.ts (stripeClientMock, stripePaymentMethodMock, createMockStripeEvent) and migrate billing tests off inline mocks Type of Change Bug fix Testing All billing + subscription tests pass (32 tests, 8 files). Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary Wrap subscription-transfer check + update in db.transaction with .for('update') row-locks in both app/api/users/me/subscription/[id]/transfer/route.ts and lib/billing/organization....

X Description: Summary Wrap subscription-transfer check + update in db.transaction with .for('update') row-locks in both app/api/users/me/subscription/[id]/transfer/route.ts and lib/billing/organ...

Opengraph URL: https://github.com/simstudioai/sim/pull/4239

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:343c04cf-7c97-cd6c-987f-e0c095520b65
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8CF2:11DC7C:55FC20:76886E:6AFB3BF6
html-safe-nonce7f37c9418a6452524ed23141963ad5a5cb77d6374f8711a0124750ec9bb6ff11
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0YyOjExREM3Qzo1NUZDMjA6NzY4ODZFOjZBRkIzQkY2IiwidmlzaXRvcl9pZCI6IjU3MTU0NzUxMzQ3NzczNDI5NjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac3651f830afb53c8295781c1f61b85ca67d7d93d2f38c4bb1c6400f72f5323062
hovercard-subject-tagpull_request:3558805068
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/4239/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Wrap subscription-transfer check + update in db.transaction with .for('update') row-locks in both app/api/users/me/subscription/[id]/transfer/route.ts and lib/billing/organization....
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None2169b0dfbef67ed6b128074a5ed45bb7d5d1859783b10178b09a7765ad5f3693
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3b4fc8df5ef1c6757e733a23e6b81b6725021823
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/4239/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F4239%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F4239%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/4239/files
Reloadhttps://github.com/simstudioai/sim/pull/4239/files
Reloadhttps://github.com/simstudioai/sim/pull/4239/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests199 (199)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
waleedlatif1/fix-expired-org-inviteshttps://github.com/simstudioai/sim/tree/waleedlatif1/fix-expired-org-invites
Conversation 17 https://github.com/simstudioai/sim/pull/4239
Commits 5 https://github.com/simstudioai/sim/pull/4239/commits
Checks 13 https://github.com/simstudioai/sim/pull/4239/checks
Files changed https://github.com/simstudioai/sim/pull/4239/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4239/files
fix(billing): close TOCTOU race in subscription transfer, centralize stripe test mocks https://github.com/simstudioai/sim/pull/4239/files#top
Show all changes 5 commits https://github.com/simstudioai/sim/pull/4239/files
bc24734 fix(billing): close TOCTOU race in subscription transfer, centralize … waleedlatif1 Apr 20, 2026 https://github.com/simstudioai/sim/pull/4239/commits/bc24734321f8a9bd666a26b70044a50dcab92a61
1519af7 more mocks waleedlatif1 Apr 20, 2026 https://github.com/simstudioai/sim/pull/4239/commits/1519af7bb7e1fcb0ea0589db64fbdacd75b8bf91
9281be3 fix(testing): provide complete Stripe.Event defaults in createMockStr… waleedlatif1 Apr 20, 2026 https://github.com/simstudioai/sim/pull/4239/commits/9281be3142fc0cebc769af32deca36837ba7d395
2dc98a3 fix(testing): make dbChainMock .for('update') chainable with .limit() waleedlatif1 Apr 20, 2026 https://github.com/simstudioai/sim/pull/4239/commits/2dc98a36e541e5ca9b40a8d8d133a41d664573c8
f14eac2 fix(billing): gate subscription transfer noop behind membership check waleedlatif1 Apr 20, 2026 https://github.com/simstudioai/sim/pull/4239/commits/f14eac21d418fa2519a0576b964d86d9bf493d8c
Clear filters https://github.com/simstudioai/sim/pull/4239/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4239/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4239/files
sim-testing.md https://github.com/simstudioai/sim/pull/4239/files#diff-f43816f1d2fbe0fc420225f0c16c8e7e5ae5ca4d7d47adc610dd79422c605474
route.test.ts https://github.com/simstudioai/sim/pull/4239/files#diff-5a169fb6c4ba4fde26cb3b3df9c7be22c941971a050512fd0f0ea8e515379490
route.ts https://github.com/simstudioai/sim/pull/4239/files#diff-d1da449e179d13d56e010bc5e426735b1119c808f7e65540baefcfd29d6c49d3
subscription.test.ts https://github.com/simstudioai/sim/pull/4239/files#diff-d9e761d0d22661eb78c13ad23e9c65e37046fc36adbe1aa7d84101bb5c7ce15e
daily-refresh.test.ts https://github.com/simstudioai/sim/pull/4239/files#diff-fe70bb3b48551ec48e3c087bfc556c283f125b3c998e63e821b6b142432f4768
organization.test.ts https://github.com/simstudioai/sim/pull/4239/files#diff-a039e5e03e58e6bf58e91f49d6d1b9c00a00b6146cb3f06fa4469274661e654c
organization.ts https://github.com/simstudioai/sim/pull/4239/files#diff-89b65bc5e4f411dfe94bcd00666debd6172f9f47cd8748a22b20f34b5aa3e52f
create-organization.test.ts https://github.com/simstudioai/sim/pull/4239/files#diff-53ece7b5e8481d551caa60e71fe5ca12204773823f80f3e94f010b2c5771bb51
seat-management.test.ts https://github.com/simstudioai/sim/pull/4239/files#diff-d30a900bd7bfd1ba118371cf8f118345fa8cce92c2661a681e5ee7b804fe8a95
invoices.test.ts https://github.com/simstudioai/sim/pull/4239/files#diff-c340dec878362883cadfd3a1950a7b6aecb3acfd9a571666173b67355684d2f4
bun.lock https://github.com/simstudioai/sim/pull/4239/files#diff-bfd0ef82a01108fa1e836c2500b98b7de8a92bb1ae352a8efcbd9d6ffcaabd60
database.mock.ts https://github.com/simstudioai/sim/pull/4239/files#diff-859f381ad1b6a93489bef08c44a1044a2c3cc6f9b98b8d973bb5b0ef893ba42b
index.ts https://github.com/simstudioai/sim/pull/4239/files#diff-38963b775b9a08da9c40dbdf25380b1bd038aa3f9f93e9c657ef549fb39f512c
stripe.mock.ts https://github.com/simstudioai/sim/pull/4239/files#diff-092183da8002e3f8ad6e6104ccc310f28df017fe8b8a6083919e34b0f7829301
.claude/rules/sim-testing.mdhttps://github.com/simstudioai/sim/pull/4239/files#diff-f43816f1d2fbe0fc420225f0c16c8e7e5ae5ca4d7d47adc610dd79422c605474
View file https://github.com/simstudioai/sim/blob/f14eac21d418fa2519a0576b964d86d9bf493d8c/.claude/rules/sim-testing.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/4239/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/4239/files#diff-f43816f1d2fbe0fc420225f0c16c8e7e5ae5ca4d7d47adc610dd79422c605474
https://github.com/simstudioai/sim/pull/4239/files#diff-f43816f1d2fbe0fc420225f0c16c8e7e5ae5ca4d7d47adc610dd79422c605474
apps/sim/app/api/users/me/subscription/[id]/transfer/route.test.tshttps://github.com/simstudioai/sim/pull/4239/files#diff-5a169fb6c4ba4fde26cb3b3df9c7be22c941971a050512fd0f0ea8e515379490
View file https://github.com/simstudioai/sim/blob/f14eac21d418fa2519a0576b964d86d9bf493d8c/apps/sim/app/api/users/me/subscription/%5Bid%5D/transfer/route.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/4239/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/4239/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/4239/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.