Significant-Gravitas/AutoGPT · error · Error
Server returned ${status}.
Error message
Server returned ${status}. What it means
Thrown by the billing BalanceCard's top-up flow when the checkout-session request returns status >= 400 and the body's detail is neither a string nor an object with a msg field. The code deliberately prefers FastAPI's {detail: ...} (string or {msg}) so users see the real Stripe-side failure; 'Server returned ${status}.' with the embedded code is the last resort when the body shape is unrecognized.
Source
Thrown at autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/BalanceCard/useBalanceCard.ts:61
const result = await requestTopUp({
data: { credit_amount: Math.round(numericAmount * 100) },
});
const status = (result as { status?: number } | undefined)?.status;
const body = result?.data as
| { checkout_url?: string; detail?: string | { msg?: string } }
| undefined;
if (status && status >= 400) {
// Surface backend error detail (FastAPI conventionally returns
// ``{"detail": "..."}``) instead of the generic "no URL" message —
// the actual failure is almost always a Stripe-side error
// (stale customer ID, missing product, invalid API key) that the
// user / their team needs to see to fix.
const detail =
typeof body?.detail === "string"
? body.detail
: (body?.detail?.msg ?? `Server returned ${status}.`);
throw new Error(detail);
}
const url = body?.checkout_url;
if (url) {
// Navigating away — don't touch React state on the unmounting tree.
window.location.href = url;
return;
}
throw new Error(
"Stripe didn't return a checkout URL. Check backend logs for the underlying Stripe error.",
);
} catch (error) {
toast({
title: "Couldn't start checkout",
description:
error instanceof Error
? error.messageView on GitHub (pinned to 9c8bb5550f)
Solutions
- Check the backend logs — the comment in code says it outright: the real cause is almost always Stripe-side and needs backend visibility.
- Verify Stripe configuration on the backend: STRIPE_SECRET_KEY, the product/price IDs for credit top-up, and webhook setup.
- Confirm the user's Stripe customer ID isn't stale (deleted customer in the Stripe dashboard) — backend re-creates or updates it if config is right.
- Match test/live mode: frontend, backend keys, and existing customer records must all be in the same mode.
Defensive patterns
Strategy: try-catch
Validate before calling
function hasFastApiDetail(body: unknown): body is { detail: string | { msg: string } } {
return (
typeof body === "object" && body !== null && "detail" in body &&
(typeof (body as any).detail === "string" ||
typeof (body as any).detail?.msg === "string")
);
} Type guard
function isCheckoutHttpError(err: unknown): boolean {
return err instanceof Error && /^Server returned \d+\.$/.test(err.message);
} Try / catch
try {
await startCheckout(amount);
} catch (error) {
// message already prefers body.detail / detail.msg — show it verbatim
toast({ title: "Couldn't start checkout", description: (error as Error).message, variant: "destructive" });
} Prevention
- Always surface FastAPI detail on >=400 (as this code does) — never swap in a friendlier generic message for billing errors.
- Verify Stripe env config in a smoke test at deploy time so misconfig is caught before users hit checkout.
- Test test-mode vs live-mode consistency across frontend, backend keys, and stored customer IDs.
When it happens
Trigger: POST to create the Stripe checkout session failing with a non-FastAPI body: an HTML error page from a proxy, an empty body, or a JSON error in a different shape — combined with 4xx/5xx statuses caused by stale Stripe customer IDs, missing STRIPE_SECRET_KEY/product config, or amount validation failures.
Common situations: Self-hosted deployments with unset/misconfigured Stripe keys; Stripe test-mode keys paired with a live-mode customer (or vice versa); deleted Stripe products/prices still referenced by backend config; gateway timeouts returning HTML.
Related errors
- Stripe didn't return a checkout URL. Check backend logs for
- Rate limit reset is not available (credit system is disabled
- str(e)
- success_url and cancel_url are required for paid tier upgrad
- Failed to fetch session (status: ${response.status})
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/072298efca41cb9b.
Report an issue: GitHub.