5 Ways Bolt and Lovable Apps Fail in Production, and How to Test Each

By Alvi Lika, Founder, Soatech

· · 9 min read

Five failure patterns that often appear in AI-built prototypes once real users arrive (tenancy, auth, webhooks, errors, accessibility), each with a test you can run first.

Prototypes built with Bolt, Lovable, v0 or an agent in Cursor are optimised for the loop that built them: describe something, see it work, describe the next thing. That loop rewards code that runs. Production also needs code that fails safely when two customers, a retried payment event or a screen reader turn up.

None of the patterns below is guaranteed to be in your app. Lovable and Bolt now scan for some of them, and a careful builder avoids most of them. They are simply the places where prototypes most often fall short of production. Each section gives a test you can run against your own staging environment, so you can find out rather than guess.

One general warning first. Generated code is only as current as its examples. Look out for APIs that have since changed: request.ip was removed from NextRequest in Next.js 15, middleware.ts became proxy.ts in Next.js 16, and Supabase's Auth Helpers packages were succeeded by @supabase/ssr. Code that relies on these may still build while doing something other than what it appears to do.

1. Tenant isolation that depends on remembering a filter

What it looks like

// Correct today, and only as long as every future query remembers the filter.
export async function listProposals(userId: string) {
  return db.query("select * from proposals where user_id = $1", [userId]);
}

The function is fine. The weakness is the pattern. Isolation exists only where someone wrote where user_id = .... An export endpoint, an admin search or a background job written later can simply forget it. In Supabase-backed apps (the default for Lovable and common in Bolt), the equivalent failure is a table with row-level security off, or a policy that is too permissive.

The test

Create two accounts in staging. As account A, create a record of every type (a proposal, a file, a comment). As account B, try to read, edit, delete and export each one by ID, through every route the app has, not just the list page. For Supabase apps, the two-account script in the RLS guide does this for you. Any success is a leak.

The fix

Make the tenant a required part of every data-access call, so a query without it does not compile:

// lib/db/proposals.ts (simplified)
export async function listProposals(tenantId: string): Promise<Proposal[]> {
  const { rows } = await db.query(
    "select id, title, status from proposals where tenant_id = $1 order by created_at desc",
    [tenantId],
  );
  return rows;
}

That is application-layer isolation. It is what Soatech's own product, Wintura, uses: every tenant-owned table carries the tenant key, and data-layer functions scope by it.

If you also want the database to refuse cross-tenant rows, add Postgres RLS, and know its exceptions. Table owners bypass policies unless you force them, and superusers and BYPASSRLS roles always bypass them (PostgreSQL docs):

alter table proposals enable row level security;
alter table proposals force row level security; -- the app's role often owns its tables

create policy tenant_isolation on proposals
  using (tenant_id = current_setting('app.tenant_id', true)::uuid)
  with check (tenant_id = current_setting('app.tenant_id', true)::uuid);

The application then runs select set_config('app.tenant_id', $1, true) inside each transaction before its queries. The true makes the setting local to the transaction, which matters with pooled connections. If the setting is missing, the policy matches nothing, so the failure is closed rather than open.

2. Authentication that only covers the happy path

What it looks like

Sign-up, sign-in and sign-out work, so the flow looks finished. The gaps are in the paths nobody demos: password reset, link expiry, session lifetime and repeated attempts.

The test

Run each of these against staging:

  • Reset enumeration. Request a reset for a registered email and for one with no account. The response body, status and timing should not tell you which is which.
  • Link reuse. Use a magic link or reset link once, then open it again. The second use should fail. Wait past the stated expiry and try a fresh link. It should fail too.
  • Cookie flags. In DevTools → Application → Cookies, the session cookie should be HttpOnly, Secure and SameSite=Lax (or Strict). It should usually have no Domain attribute: a host-only cookie is narrower than one set for the parent domain, which is also sent to every subdomain.
  • Sign-out. Copy the session cookie, sign out, then send a request with the old cookie. It should be rejected.
  • Repeated attempts. A scripted burst of failed sign-ins against your own staging app should start returning 429 or a lockout.

The fix

Use a maintained auth library or your platform's auth rather than hand-rolled tokens, and configure it rather than accepting defaults. Supabase Auth, for example, has built-in, configurable rate limits on sign-in, sign-up and recovery. Then turn the tests above into automated ones so they keep passing after the next regeneration.

3. Webhooks that trust whatever arrives

What it looks like

// Accepts any JSON posted to the URL, and acts on it every time it arrives.
export async function POST(req: Request) {
  const event = await req.json();
  if (event.type === "checkout.session.completed") await fulfilOrder(event.data.object);
  return Response.json({ received: true });
}

Anyone who finds the URL can post a fake "payment completed" event. And because providers retry, a real event can be processed twice.

The test

Against your own staging endpoint, send a POST with a made-up event body and no valid signature. It should return 400 and do nothing. Then deliver the same real test event twice (Stripe's CLI can resend events). It should produce one order, one email and one invoice, not two.

The fix

Verify the signature over the raw body, and record each event ID once before acting. Stripe documents both requirements: the raw body is needed for verification, and the same event may arrive more than once. A complete Next.js handler is in the Cursor security review checklist. A Supabase Edge Function version is in the Lovable launch checklist. Apply the same rule to every inbound webhook, whether it comes from payments, email or storage.

4. Error handling that treats every failure the same

What it looks like

try {
  const result = await externalApi.call();
  return Response.json({ result });
} catch (error) {
  console.error(error);
  return Response.json({ error: "Something went wrong" }, { status: 500 });
}

The user cannot tell "try again in a minute" from "this will never work" or "it may already have happened". The code cannot decide whether a retry is safe. And a console.error that nobody reads is not monitoring.

The test

In staging, make the external dependency fail in each of its ways: an invalid key (rejected), a rate limit (429), an outage or timeout. Then check three things. Does the UI say something different and accurate for each? Is the failure recorded somewhere a person will see it? And for actions with side effects (sending, charging), can the user tell whether it happened?

The fix

Classify failures where they occur, and decide the behaviour for each class:

// lib/provider.ts (simplified)
type ProviderResult<T> =
  | { kind: "ok"; body: T }
  | { kind: "rate_limited"; retryAfterSeconds: number } // retry later, with backoff
  | { kind: "unavailable" }                            // retry later; tell the user it's delayed
  | { kind: "rejected"; status: number };             // our request was wrong: don't retry

export async function callProvider<T>(url: string, init: RequestInit): Promise<ProviderResult<T>> {
  // A timeout throws. For actions with side effects, treat it as "outcome unknown", not "failed".
  const res = await fetch(url, { ...init, signal: AbortSignal.timeout(10_000) });

  if (res.ok) return { kind: "ok", body: (await res.json()) as T };
  if (res.status === 429) {
    const header = Number(res.headers.get("retry-after"));
    return { kind: "rate_limited", retryAfterSeconds: Number.isFinite(header) && header > 0 ? header : 30 };
  }
  if (res.status >= 500) return { kind: "unavailable" };
  return { kind: "rejected", status: res.status };
}

The caller maps each kind to a response, a message and, where relevant, a queued retry. Retrying an action that charges or sends is only safe if the operation is idempotent. Pass the provider an idempotency key where it supports one. Log every non-ok result with a request ID, through whatever error tracking you actually monitor.

5. No accessibility coverage

What it looks like

The interface looks clean and works with a mouse. Nobody has tried it with only a keyboard, a screen reader or 200% zoom. Icon-only buttons have no accessible name, modals don't trap or return focus, and some text fails contrast.

The test

Unplug the mouse and complete the main journey (sign up, do the core task, pay) with Tab, Shift+Tab, Enter, Space and Escape. You should always be able to see where focus is. Then add an automated check to your end-to-end tests:

// tests/a11y.spec.ts (simplified)
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

for (const path of ["/", "/signup", "/login"]) {
  test(`${path} has no detectable WCAG A/AA violations`, async ({ page }) => {
    await page.goto(path);
    const results = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa"]).analyze();
    expect(results.violations).toEqual([]);
  });
}

The fix

Fix what the scan reports, then fix what the keyboard test found, because automated tools catch only part of the problem. Common repairs: a visible focus style, labels associated with every input, accessible names on icon buttons, focus moved into and back out of dialogs, and respect for prefers-reduced-motion. Add signed-in pages to the scan once the test can log in.

What the five have in common

Each of these fails only when something other than the happy path happens: a second customer, a retried event, a failing provider, a different way of using the interface. That is why they survive demos and show up after launch, and why the tests above are worth automating rather than running once.

The UI layer of a generated prototype often carries into production with little change. The work is usually underneath it. If you run these tests and the results are mixed, a written diagnosis tells you what to fix first. If you already know the gaps, Prototype to Production brings an AI-built prototype to a written production baseline.

Ran these tests and not sure what to fix first?

See the Production Audit

Working on a feature this article touches? A 30-minute call is the quickest way to scope it.

Discuss your project