fix(enterprise): await session.merge in billing success callback - #226
Merged
Conversation
The Stripe checkout success_callback is async, but session.merge() on line 321 was called without await. SQLAlchemy's async session.merge() returns a coroutine, so without await it never executes — the billing session status was never persisted as 'completed' and the merge silently dropped. The sibling code path at line 381 already uses the correct 'await session.merge(billing_session)' pattern. Fixes https://linear.app/all-hands-ai/issue/OHE-3126 Co-authored-by: openhands <openhands@all-hands.dev>
There was a problem hiding this comment.
Pull request overview
This PR fixes an async SQLAlchemy usage issue in the Enterprise Stripe checkout success callback by awaiting AsyncSession.merge(), ensuring the merge operation actually executes instead of returning an unawaited coroutine.
Changes:
- Add missing
awaitbeforesession.merge(billing_session)insuccess_callbackto correctly persist the updated billing session state.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
tofarr
enabled auto-merge (squash)
August 21, 2026 17:34
saurya
approved these changes
Aug 21, 2026
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
|
🚀 Released in 1.55.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
AGENT:
Why
The Stripe checkout
success_callbackinenterprise/server/routes/billing.pyis an async function, butsession.merge(billing_session)(line 321) was called withoutawait. SQLAlchemy's asyncsession.merge()returns a coroutine that never executes unless awaited, so the merge silently dropped — the billing session status was never persisted ascompletedand credit-purchase transactions failed to record (matches OHE-3126: "Error when loading billing credits").The sibling code path at line 381 already uses the correct
await session.merge(billing_session)pattern, confirming this is an oversight.This PR was created by an AI agent (OpenHands) on behalf of the user.
Summary
awaitbeforesession.merge(billing_session)in the Stripesuccess_callbackso the billing session status is actually persisted.Issue Number
https://linear.app/all-hands-ai/issue/OHE-3126
How to Test
This was not runtime-tested in this environment (requires Stripe test keys and an async DB session). To verify:
GET /billing/success?session_id=...) with a completed test checkout session.BillingSessionrow is updated tostatus='completed'andpriceis set.await session.commit().Static checks performed:
mypypasses viapre-commit run --config ./dev_config/python/.pre-commit-config.yaml.Video/Screenshots
N/A — one-line fix, no UI change.
Type
Notes
awaitwas introduced in the repo's root commit (6393c240e, PR #15356) and has been present since; it was never touched by subsequent billing changes (PR fix: protect personal organization billing credits #167).Enterprise server image for this PR: