{"record":{"id":"55464ddeb75cf66e","repo":"moeru-ai/airi","slug":"invalid-package","errorCode":"INVALID_PACKAGE","errorMessage":"Invalid price","messagePattern":"Invalid price","errorType":"validation","errorClass":"ApiError","httpStatus":400,"severity":"error","filePath":"server/apps/api/src/routes/stripe/operations/checkout.ts","lineNumber":41,"sourceCode":"  productEventService: ProductEventService | null,\n) {\n  return async (\n    user: { id: string, email: string },\n    body: unknown,\n    request: Request,\n  ): Promise<{ url: string }> => {\n    const fluxProductId = await configKV.getOptional('STRIPE_FLUX_PRODUCT_ID')\n    if (!stripe || !priceCatalog || !fluxProductId)\n      throw createServiceUnavailableError('Stripe is not configured', 'STRIPE_NOT_CONFIGURED')\n\n    const parsed = safeParse(CheckoutBodySchema, body)\n    if (!parsed.success)\n      throw createBadRequestError('Invalid checkout request', 'INVALID_REQUEST', parsed.issues)\n\n    const { stripePriceId, currency } = parsed.output\n    const price = await priceCatalog.findActivePrice(fluxProductId, stripePriceId)\n    if (!price)\n      throw createBadRequestError('Invalid price', 'INVALID_PACKAGE', { stripePriceId })\n\n    const fluxAmount = Number(price.metadata.fluxAmount)\n    if (!Number.isFinite(fluxAmount) || fluxAmount <= 0)\n      throw createBadRequestError('Price is missing fluxAmount metadata', 'INVALID_PACKAGE', { stripePriceId })\n\n    const redirectBase = resolveCheckoutRedirectBase(request, env.ADDITIONAL_TRUSTED_ORIGINS, env.WEB_APP_URL)\n    const openpanelIdentity = readOpenpanelIdentityHeaders(request)\n\n    const order = await payment.openPending({\n      userId: user.id,\n      processor: 'stripe',\n      packKey: stripePriceId,\n      fluxAmount,\n      currency,\n    })\n\n    const sessionParams: Stripe.Checkout.SessionCreateParams = {\n      line_items: [{ price: stripePriceId, quantity: 1 }],","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/moeru-ai/airi/blob/438a067dde47aa0bdb46c2323d1fe293dc805218/server/apps/api/src/routes/stripe/operations/checkout.ts#L23-L59","documentation":"The submitted stripePriceId is valid syntactically but priceCatalog.findActivePrice found no active price matching it for the configured flux product. The API rejects with 400 INVALID_PACKAGE because checkout cannot bill against an unknown, inactive, or foreign price.","triggerScenarios":"POSTing checkout with a stripePriceId that belongs to a different Stripe product than STRIPE_FLUX_PRODUCT_ID, an archived/inactive price, or a typo/nonexistent price ID.","commonSituations":"Hardcoded price IDs left over after re-creating prices in Stripe dashboard; staging client pointing at production price IDs (or vice versa); price archived during a pricing change while clients still cache it.","solutions":["Use a price ID that belongs to the product configured as STRIPE_FLUX_PRODUCT_ID and is currently active.","Fetch the current active price from the price catalog/API instead of hardcoding it in the client.","Verify you are hitting the right environment (test vs live mode price IDs differ).","Re-create/activate the price in Stripe if it was archived unintentionally."],"exampleFix":"// before\nbody: { stripePriceId: 'price_old_archived', currency: 'usd' }\n// after\nbody: { stripePriceId: await fetchActivePriceId(), currency: 'usd' }","handlingStrategy":"validation","validationCode":"// Only offer prices known to be active and belonging to the flux product\nconst activePriceIds = new Set((await fetchCatalogPrices()).map(p => p.id))\nif (!activePriceIds.has(stripePriceId)) throw new Error('price not in active catalog')","typeGuard":null,"tryCatchPattern":"try {\n  await checkout({ stripePriceId, currency })\n} catch (e) {\n  if (e.code === 'INVALID_PACKAGE') {\n    // refresh price catalog and ask user to reselect\n  }\n}","preventionTips":["Never hardcode Stripe price IDs in clients; fetch them from the catalog API.","Refresh cached prices on app start and after pricing changes.","Keep test-mode and live-mode price IDs in separate config."],"tags":["stripe","pricing","bad-request"],"backgroundTag":"resource-not-found","analyzedSha":"438a067dde47aa0bdb46c2323d1fe293dc805218","analyzedAt":"2026-09-17T01:14:42.644Z","contentChangedAt":"2026-09-17T01:14:42.644Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}