Skip to content

Subscription webhooks fail because schema resolves to "undefined" instead of default "stripe" #227

@shinchannn

Description

@shinchannn

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When creating a StripeSync instance without explicitly setting the schema parameter, subscription-related webhooks processing (such as customer.subscription.created) fail during processing. The issue occurs inside the markDeletedSubscriptionItems() method, where this.config.schema resolves to undefined instead of using the default "stripe" schema.

This leads to PostgreSQL errors like:

relation "undefined.subscription_items" does not exist

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Initialize StripeSync without providing the schema parameter
const stripeSync = new StripeSync({
  stripeSecretKey: process.env.STRIPE_SECRET_KEY!,
  stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
  databaseUrl: process.env.DATABASE_URL!,
  // ❌ schema not provided
});
  1. Run migrations
  2. Create a webhook handler, for example in Next.js
export async function POST(req: Request) {
  const body = await req.text();
  const signature = req.headers.get("stripe-signature")!;

  try {
    await stripeSync.processWebhook(body, signature);
    return Response.json({ received: true });
  } catch (err) {
    console.error("Webhook error:", err);
    return new Response("Webhook Error", { status: 400 });
  }
}
  1. Trigger subcription.customer.created webhook

Expected behavior

When the schema parameter is not provided, subcripition related webhook handlers should default to using the "stripe" schema—just like the other handlers already do.

System information

  • OS: macOS
  • Version of @supabase/stripe-sync-engine: 0.45.0

Additional context

Same issue was mentioned in this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions