{"record":{"id":"c93f2d6a20a17ee5","repo":"hcengineering/platform","slug":"missing-productids-for-plan-plankey","errorCode":null,"errorMessage":"Missing productIds for plan: ${planKey}","messagePattern":"Missing productIds for plan: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"services/payment/pod-payment/src/providers/polar/provider.ts","lineNumber":104,"sourceCode":"      if (this.subscriptionPlans[plan] === undefined) {\n        throw new Error(`Missing plan in config: ${plan}`)\n      }\n    }\n  }\n\n  async createSubscription (\n    ctx: MeasureContext,\n    request: SubscribeRequest,\n    workspaceUuid: WorkspaceUuid,\n    workspaceUrl: string,\n    accountUuid: string\n  ): Promise<CheckoutResponse> {\n    ctx.info('Creating Polar subscription', { type: request.type, plan: request.plan })\n\n    const planKey = getPlanKey(request.type, request.plan)\n    const productIds = this.subscriptionPlans[planKey]\n    if (productIds === undefined) {\n      throw new Error(`Missing productIds for plan: ${planKey}`)\n    }\n    const successUrl = `${this.frontUrl}/workbench/${workspaceUrl}/setting/setting/billing/subscriptions?payment=success&checkout_id={CHECKOUT_ID}`\n    const returnUrl = `${this.frontUrl}/workbench/${workspaceUrl}/setting/setting/billing/subscriptions?payment=canceled`\n    const response = await this.polar.createCheckout(ctx, {\n      productIds,\n      successUrl,\n      returnUrl,\n      externalCustomerId: accountUuid,\n      customerEmail: request.customerEmail,\n      customerName: request.customerName,\n      metadata: {\n        workspaceUuid,\n        subscriptionType: request.type,\n        subscriptionPlan: request.plan\n      }\n    })\n\n    return {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/payment/pod-payment/src/providers/polar/provider.ts#L86-L122","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the missing planKey -> Polar productIds entry to the provider's subscriptionPlans configuration and redeploy","Check the exact planKey value in the error message and fix the caller to send a supported plan/type combination","Align getPlanKey with the configured keys after any type/plan rename","Verify against the Polar dashboard that product IDs exist for that plan"],"exampleFix":"// before\nsubscriptionPlans: { 'tier:free': ['prod_free'], 'tier:team': ['prod_team'] }\n// request plan 'enterprise' -> throw\n// after\nsubscriptionPlans: { 'tier:free': ['prod_free'], 'tier:team': ['prod_team'], 'tier:enterprise': ['prod_ent'] }","handlingStrategy":"validation","validationCode":"const planKey = getPlanKey(request.type, request.plan)\nif (provider.subscriptionPlans?.[planKey] === undefined) {\n  throw new Error(`Plan ${planKey} is not available; choose one of ${Object.keys(provider.subscriptionPlans ?? {}).join(', ')}`)\n}","typeGuard":"function isConfiguredPlan(provider: PolarProvider, planKey: string): planKey is keyof typeof provider.subscriptionPlans {\n  return provider.subscriptionPlans?.[planKey] !== undefined\n}","tryCatchPattern":"try {\n  await provider.createSubscription(ctx, request)\n} catch (e) {\n  if (e.message.startsWith('Missing productIds for plan')) {\n    // surface 400 'plan not available' to the client\n  } else throw e\n}","preventionTips":["Keep subscriptionPlans config in sync with the plans advertised in the billing UI","Expose the list of available plans via an API and validate against it client-side","Add a startup/unit test that every advertised plan key has product IDs","Grep the error planKey against config on occurrence"],"tags":["configuration","payment","polar","plans"],"backgroundTag":"missing-plan-configuration","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}