Skip to content

Conversation

@felixschmetz
Copy link
Collaborator

@felixschmetz felixschmetz commented Oct 22, 2025

Fix issues in the admin dashboard's Create Enterprise Organization flow that prevented successful organization creation with proper billing setup.

Backend fixes (admin.py):

  • Fix request schema to accept flat JSON body instead of query parameters
  • Add CreateEnterpriseOrganizationRequest schema matching frontend payload
  • Remove invalid Organization model fields (created_by_email, modified_by_email)
  • Fix SQLAlchemy detached instance errors by:
    • Extracting all user attributes before entering UnitOfWork context
    • Capturing org_id before UnitOfWork commit
    • Reloading organization with CRUD layer after creation
  • Return dict instead of Pydantic model to avoid FastAPI re-serialization issues
  • Require Stripe to be enabled (production-only endpoint)

Frontend fixes (AdminDashboard.tsx):

  • Conditionally hide "Upgrade" button for organizations already on enterprise plan based on billing_plan !== 'enterprise'

Summary by cubic

Fixes the admin “Create Enterprise Organization” flow so orgs are created on the enterprise plan with proper billing, and the dashboard UI reflects enterprise status. Backend now accepts a flat JSON body and avoids SQLAlchemy state issues during creation.

  • Bug Fixes
    • Switched to CreateEnterpriseOrganizationRequest (flat JSON) and removed invalid org fields; response returns a dict to avoid FastAPI/SQLAlchemy re-serialization problems.
    • Prevented detached-instance errors by reading user data before UnitOfWork, capturing org_id before commit, and reloading via CRUD with enrich.
    • Required Stripe to be enabled; creates customer and enterprise billing, with failures logged but not blocking org creation.
    • AdminDashboard: shows “Upgrade” only when billing_plan is not 'enterprise'.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@felixschmetz felixschmetz marked this pull request as draft October 22, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant