FlowiseAI/Flowise · error · Error
Subscription ID is required
Error message
Subscription ID is required
What it means
Immediately after the customer-ID check in createStripeCustomerPortalSession, the code reads req.user.activeOrganizationSubscriptionId and throws a generic Error if it's falsy. The portal configuration and session creation both need a subscription context, so a missing subscription ID is a hard precondition. This fires for org customers who exist in Stripe but have no subscription tied to the active organization.
Source
Thrown at packages/server/src/StripeManager.ts:134
subsriptionDetails: this.getSubscriptionObject(subscription)
})
return features
}
public async createStripeCustomerPortalSession(req: Request) {
if (!this.stripe) {
throw new Error('Stripe is not initialized')
}
const customerId = req.user?.activeOrganizationCustomerId
if (!customerId) {
throw new Error('Customer ID is required')
}
const subscriptionId = req.user?.activeOrganizationSubscriptionId
if (!subscriptionId) {
throw new Error('Subscription ID is required')
}
try {
const prodPriceIds = await this.getPriceIds()
const configuration = await this.createPortalConfiguration(prodPriceIds)
const portalSession = await this.stripe.billingPortal.sessions.create({
customer: customerId,
configuration: configuration.id,
return_url: `${process.env.APP_URL}/account`
/* We can't have flow_data because it does not support multiple subscription items
flow_data: {
type: 'subscription_update',
subscription_update: {
subscription: subscriptionId
},
after_completion: {
type: 'redirect',View on GitHub (pinned to abe4a8601a)
Solutions
- Confirm the active organization completed subscription checkout so activeOrganizationSubscriptionId is persisted on the user/org.
- Check the auth middleware persists the subscription ID alongside the customer ID after a successful checkout webhook.
- On the client, gate the portal action on subscription presence (not just customer presence).
- If the subscription was canceled and the ID cleared, route the user to re-subscribe rather than the portal.
Example fix
// before
const subscriptionId = req.user?.activeOrganizationSubscriptionId
if (!subscriptionId) {
throw new Error('Subscription ID is required')
}
// after
if (!subscriptionId) {
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Active organization has no subscription. Start a subscription first.')
} Defensive patterns
Strategy: validation
Validate before calling
function requireOrgSubscription(user: unknown): asserts user is { activeOrganizationSubscriptionId: string } {
const u = user as any
if (!u?.activeOrganizationSubscriptionId) {
throw new Error('Active organization has no subscription. Start a subscription first.')
}
}
requireOrgSubscription(req.user) Type guard
function hasOrgSubscriptionId(user: unknown): user is { activeOrganizationSubscriptionId: string } {
return typeof (user as any)?.activeOrganizationSubscriptionId === 'string' && (user as any).activeOrganizationSubscriptionId.length > 0
} Try / catch
try {
const session = await stripeManager.createStripeCustomerPortalSession(req)
} catch (err) {
if (err instanceof Error && err.message === 'Subscription ID is required') {
return res.status(StatusCodes.BAD_REQUEST).json({ error: 'No active subscription for this organization' })
}
throw err
} Prevention
- Persist the subscription ID on the org record via the checkout-completed webhook.
- Verify the auth middleware reads the subscription ID into req.user.
- Gate the portal action on subscription presence, not just customer presence.
- After cancellation, route users to re-subscribe instead of the portal.
When it happens
Trigger: An authenticated user with a Stripe customer record but no subscription on their active organization calls the portal-session endpoint. Also when activeOrganizationSubscriptionId isn't set by the auth middleware despite a subscription existing.
Common situations: Customer created during signup but checkout/subscription step abandoned. Org has a customer ID persisted but the subscription ID field was never written back after checkout. Middleware/auth desync after subscription cancellation removed the ID.
Related errors
- Customer ID is required
- Stripe manager is not initialized
- No subscription items found
- Subscription is canceled
- Subscription is canceled
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/daf2dcd866d8a942.
Report an issue: GitHub.