hcengineering/platform · error

Missing productIds for plan: ${planKey}

Error message

Missing productIds for plan: ${planKey}

What it means

The Polar payment provider maps a subscription request (type + plan) to a configured set of Polar product IDs via getPlanKey and this.subscriptionPlans. If the computed planKey has no entry in subscriptionPlans, the provider cannot create a checkout and throws 'Missing productIds for plan: <planKey>'. It indicates the deployment's Polar plan configuration is missing that tier/plan combination.

Source

Thrown at services/payment/pod-payment/src/providers/polar/provider.ts:104

      if (this.subscriptionPlans[plan] === undefined) {
        throw new Error(`Missing plan in config: ${plan}`)
      }
    }
  }

  async createSubscription (
    ctx: MeasureContext,
    request: SubscribeRequest,
    workspaceUuid: WorkspaceUuid,
    workspaceUrl: string,
    accountUuid: string
  ): Promise<CheckoutResponse> {
    ctx.info('Creating Polar subscription', { type: request.type, plan: request.plan })

    const planKey = getPlanKey(request.type, request.plan)
    const productIds = this.subscriptionPlans[planKey]
    if (productIds === undefined) {
      throw new Error(`Missing productIds for plan: ${planKey}`)
    }
    const successUrl = `${this.frontUrl}/workbench/${workspaceUrl}/setting/setting/billing/subscriptions?payment=success&checkout_id={CHECKOUT_ID}`
    const returnUrl = `${this.frontUrl}/workbench/${workspaceUrl}/setting/setting/billing/subscriptions?payment=canceled`
    const response = await this.polar.createCheckout(ctx, {
      productIds,
      successUrl,
      returnUrl,
      externalCustomerId: accountUuid,
      customerEmail: request.customerEmail,
      customerName: request.customerName,
      metadata: {
        workspaceUuid,
        subscriptionType: request.type,
        subscriptionPlan: request.plan
      }
    })

    return {

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Add the missing planKey -> Polar productIds entry to the provider's subscriptionPlans configuration and redeploy
  2. Check the exact planKey value in the error message and fix the caller to send a supported plan/type combination
  3. Align getPlanKey with the configured keys after any type/plan rename
  4. Verify against the Polar dashboard that product IDs exist for that plan

Example fix

// before
subscriptionPlans: { 'tier:free': ['prod_free'], 'tier:team': ['prod_team'] }
// request plan 'enterprise' -> throw
// after
subscriptionPlans: { 'tier:free': ['prod_free'], 'tier:team': ['prod_team'], 'tier:enterprise': ['prod_ent'] }
Defensive patterns

Strategy: validation

Validate before calling

const planKey = getPlanKey(request.type, request.plan)
if (provider.subscriptionPlans?.[planKey] === undefined) {
  throw new Error(`Plan ${planKey} is not available; choose one of ${Object.keys(provider.subscriptionPlans ?? {}).join(', ')}`)
}

Type guard

function isConfiguredPlan(provider: PolarProvider, planKey: string): planKey is keyof typeof provider.subscriptionPlans {
  return provider.subscriptionPlans?.[planKey] !== undefined
}

Try / catch

try {
  await provider.createSubscription(ctx, request)
} catch (e) {
  if (e.message.startsWith('Missing productIds for plan')) {
    // surface 400 'plan not available' to the client
  } else throw e
}

Prevention

When it happens

Trigger: createSubscription invoked with a request.type/request.plan whose getPlanKey(result) is absent from this.subscriptionPlans — e.g. plan 'enterprise' when only 'free'|'starter'|'team' are configured, or type 'Tier' vs a map keyed for 'Vendor' plans.

Common situations: New plan added to product UI before Polar provider config (env/JSON subscriptionPlans) was updated; typo in plan name from the client; mismatch between plan keys after a rename/refactor; regional deployments with different plan catalogs.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/c93f2d6a20a17ee5. Report an issue: GitHub.