Skip to content

fix(enterprise): await session.merge in billing success callback - #226

Merged
tofarr merged 1 commit into
mainfrom
fix/await-billing-merge
Aug 21, 2026
Merged

fix(enterprise): await session.merge in billing success callback#226
tofarr merged 1 commit into
mainfrom
fix/await-billing-merge

Conversation

@tofarr

@tofarr tofarr commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

The Stripe checkout success_callback in enterprise/server/routes/billing.py is an async function, but session.merge(billing_session) (line 321) was called without await. SQLAlchemy's async session.merge() returns a coroutine that never executes unless awaited, so the merge silently dropped — the billing session status was never persisted as completed and 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

  • Add the missing await before session.merge(billing_session) in the Stripe success_callback so 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:

  1. Trigger the Stripe checkout success callback (GET /billing/success?session_id=...) with a completed test checkout session.
  2. Confirm the BillingSession row is updated to status='completed' and price is set.
  3. Previously this dropped the merge; now it should commit cleanly via await session.commit().

Static checks performed: mypy passes via pre-commit run --config ./dev_config/python/.pre-commit-config.yaml.

Video/Screenshots

N/A — one-line fix, no UI change.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-ac675b6

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>
@github-actions github-actions Bot added the type: fix A bug fix label Aug 21, 2026
@tofarr
tofarr requested a lite review from Copilot August 21, 2026 17:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 await before session.merge(billing_session) in success_callback to 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.

@hieptl hieptl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you! 🙏

@tofarr
tofarr enabled auto-merge (squash) August 21, 2026 17:34
@tofarr
tofarr merged commit 1d258ad into main Aug 21, 2026
23 checks passed
@tofarr
tofarr deleted the fix/await-billing-merge branch August 21, 2026 17:38
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  enterprise/server/routes
  billing.py 318-322
Project Total  

This report was generated by python-coverage-comment-action

@openhands-release-bot

Copy link
Copy Markdown

🚀 Released in 1.55.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.55.0 Shipped in 1.55.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants