Skip to main content

Common Issues

Solutions to frequently encountered problems in Artbase Studio.

Authentication Issues

"Invalid JWT" Error

Symptoms: API requests fail with 401 Unauthorized

Causes:

  • Expired JWT token
  • Mismatched Supabase keys
  • Clock skew between client and server

Solutions:

  1. Refresh the session:

    const { data, error } = await supabase.auth.refreshSession();
  2. Verify environment variables:

    # Check Supabase URL matches
    echo $NEXT_PUBLIC_SUPABASE_URL
  3. Clear local storage and re-login

"Permission Denied" on Database Query

Symptoms: Query returns empty or throws RLS error

Causes:

  • User not in organization
  • Missing RLS policy
  • Wrong user context

Solutions:

  1. Check organization membership:

    SELECT * FROM organization_members
    WHERE user_id = 'your-user-id';
  2. Verify RLS policies:

    SELECT * FROM pg_policies
    WHERE tablename = 'your_table';
  3. Test with service role (temporarily):

    const adminClient = createClient(url, serviceRoleKey);

OAuth Login Fails

Symptoms: Redirect loop or callback error

Causes:

  • Misconfigured redirect URLs
  • Missing OAuth credentials
  • CORS issues

Solutions:

  1. Verify redirect URL in Supabase Dashboard
  2. Check OAuth provider credentials
  3. Ensure HTTPS in production

Checkout Issues

Payment Intent Creation Fails

Symptoms: "Error creating payment intent"

Causes:

  • Invalid Stripe key
  • Missing required fields
  • Stripe account issue

Solutions:

  1. Verify Stripe keys:

    # Test API key
    curl https://api.stripe.com/v1/balance \
    -u sk_test_xxx:
  2. Check request payload:

    console.log({ amount, currency, customer_email });
  3. Review Stripe Dashboard for errors

Platform Fee Not Calculated

Symptoms: Orders show $0 platform fee

Causes:

  • Founding artist exemption active
  • Missing plan configuration
  • Organization not linked to plan

Solutions:

  1. Check founding artist status:

    SELECT is_founding_artist, founding_artist_start_date
    FROM organizations WHERE id = 'org-id';
  2. Verify plan has commission rate:

    SELECT features->>'commission_rate' FROM plans
    WHERE id = 'plan-id';

Webhook Not Processing

Symptoms: Orders not created after successful payment

Causes:

  • Wrong webhook secret
  • Endpoint not deployed
  • Signature verification failing

Solutions:

  1. Verify webhook secret in environment:

    echo $STRIPE_WEBHOOK_SECRET
  2. Check Stripe webhook logs:

    • Stripe Dashboard → Developers → Webhooks
  3. Test webhook locally:

    stripe listen --forward-to localhost:3000/api/webhooks/stripe

Channel Sync Issues

Etsy Orders Not Syncing

Symptoms: No new orders appearing from Etsy

Causes:

  • Expired OAuth tokens
  • API rate limiting
  • Sync service not running

Solutions:

  1. Check token expiry:

    SELECT token_expires_at FROM channel_accounts
    WHERE channel_id = (SELECT id FROM channels WHERE slug = 'etsy');
  2. Review sync service logs:

    railway logs --service etsy-sync
  3. Re-authorize Etsy connection

"Invalid Grant" OAuth Error

Symptoms: Token refresh fails

Causes:

  • Refresh token expired
  • User revoked access
  • Encryption key mismatch

Solutions:

  1. Disconnect and reconnect channel
  2. Verify encryption key matches across services
  3. Check Etsy app permissions

Email Issues

Emails Not Sending

Symptoms: Campaign shows "sent" but no deliveries

Causes:

  • Invalid Resend API key
  • Domain not verified
  • Subscriber list empty

Solutions:

  1. Verify Resend API key:

    curl -X POST https://api.resend.com/emails \
    -H "Authorization: Bearer re_xxx" \
    -d '{"from": "test@yourdomain.com", "to": "test@example.com", "subject": "Test"}'
  2. Check domain verification in Resend Dashboard

  3. Verify subscribers exist:

    SELECT COUNT(*) FROM email_subscribers
    WHERE org_id = 'org-id' AND status = 'active';

High Bounce Rate

Symptoms: Many emails bouncing

Causes:

  • Invalid email addresses
  • Spam complaints
  • Domain reputation issues

Solutions:

  1. Clean subscriber list:

    UPDATE email_subscribers
    SET status = 'bounced'
    WHERE email IN (SELECT email FROM bounced_emails);
  2. Implement double opt-in

  3. Review email content for spam triggers


Performance Issues

Slow Page Load

Symptoms: Pages taking >3 seconds to load

Causes:

  • Large API responses
  • Missing database indexes
  • Unoptimized queries

Solutions:

  1. Add pagination:

    const { data } = await supabase
    .from('products')
    .select('*')
    .range(0, 19);
  2. Create indexes:

    CREATE INDEX idx_products_org_status
    ON products(org_id, status);
  3. Use React Query caching

Database Connection Exhausted

Symptoms: "Too many connections" error

Causes:

  • Connection leaks
  • Missing connection pooling
  • Too many concurrent requests

Solutions:

  1. Enable PgBouncer in Supabase
  2. Use connection pooling URL
  3. Close connections properly:
    // Connections auto-close with Supabase client
    // Ensure not creating new clients per request

Flutter Issues

Provider Not Found

Symptoms: ProviderNotFoundException

Causes:

  • Missing ProviderScope
  • Wrong provider reference
  • Provider not initialized

Solutions:

  1. Wrap app with ProviderScope:

    runApp(ProviderScope(child: MyApp()));
  2. Check provider is properly defined:

    final myProvider = FutureProvider<Data>((ref) async {
    // Implementation
    });

Build Failed on iOS

Symptoms: Xcode build errors

Causes:

  • Pod issues
  • Missing permissions
  • Swift version mismatch

Solutions:

  1. Clean and rebuild:

    cd ios && pod deintegrate && pod install
    flutter clean && flutter run
  2. Update pods:

    cd ios && pod update

Getting Help

If you can't resolve an issue:

  1. Check logs for specific error messages
  2. Search GitHub Issues for similar problems
  3. Join our Discord for community support
  4. Contact support with:
    • Error message
    • Steps to reproduce
    • Environment details (browser, OS, etc.)