antiwork/gumroad · critical · ResponseError

Something went wrong.

Error message

Something went wrong.

What it means

ResponseError ("Something went wrong.") thrown by getSurcharges when POST /customer_surcharge (CustomerSurchargeController#calculate_all) answers non-2xx. This runs in the buyer-facing purchase flow to compute currency surcharges, so a failure here degrades checkout. request() pre-converts 5xx/429/network/abort into other error types, so this throw is a 4xx: 422 for invalid currency/amount data, 404 for an unknown product, 401 for auth problems.

Source

Thrown at app/javascript/data/customer_surcharge.ts:83

          tax_cents: number;
          shipping_cents: number;
          total_cents: number;
        }[]
      | undefined;
  } | null;
  detected_buyer_currency?: string | null | undefined;
  available_buyer_currencies?: { code: string; label: string }[] | undefined;
};

export const getSurcharges = async (data: GetSurchargesRequest, abortSignal?: AbortSignal) => {
  const response = await request({
    method: "POST",
    accept: "json",
    url: Routes.customer_surcharges_path(),
    abortSignal,
    data,
  });
  if (!response.ok) throw new ResponseError();
  return typia.assert<SurchargesResponse>(await response.json());
};

View on GitHub (pinned to afeacbd394)

Solutions

  1. DevTools → Network: inspect the /customer_surcharge response body — a 422 names the invalid field.
  2. Confirm the currency codes sent are uppercase ISO 4217 codes the server supports; log detected_buyer_currency when it fails.
  3. 404: verify the product/links involved are still published and purchasable.
  4. Since this sits in the purchase flow, add a fallback in the UI (hide the surcharge line or block the buy button) rather than letting the error break checkout.

Example fix

// before
const response = await request({ method: "POST", accept: "json", url: Routes.customer_surcharges_path(), abortSignal, data });

// after — validate the payload shape the server charges on
const ISO_4217 = /^[A-Z]{3}$/;
if (!data.currency_code || !ISO_4217.test(data.currency_code))
  throw new Error(`Unsupported currency: ${String(data.currency_code)}`);
const response = await request({ method: "POST", accept: "json", url: Routes.customer_surcharges_path(), abortSignal, data });
Defensive patterns

Strategy: fallback

Validate before calling

const ISO_4217 = /^[A-Z]{3}$/;
const surchargeRequestOk =
  (data.currency_code === undefined || ISO_4217.test(data.currency_code)) &&
  (data.detected_buyer_currency === null || data.detected_buyer_currency === undefined || ISO_4217.test(data.detected_buyer_currency)) &&
  (data.available_buyer_currencies === undefined || data.available_buyer_currencies.every((c) => ISO_4217.test(c.code) && c.label.length > 0));
if (!surchargeRequestOk) return; // skip the call rather than break checkout
await getSurcharges(data, abortSignal);

Type guard

const isSurchargesResponse = (v: unknown): v is SurchargesResponse =>
  typeof v === "object" && v !== null && "surcharges" in v;

Try / catch

import { assertResponseError } from "$app/utils/request";
try {
  const { surcharges } = await getSurcharges(data, abortSignal);
} catch (e) {
  if (e instanceof AbortError) return; // unmounts are not failures
  assertResponseError(e);
  hideSurchargeLine(); // keep checkout usable without the surcharge breakdown
}

Prevention

When it happens

Trigger: Posting a detected_buyer_currency or available_buyer_currencies entry the server does not support (422); calculating surcharges for a product that was just unpublished or deleted (404); a session/auth problem on the purchase page (401); aborting is explicitly NOT this error — abortSignal produces AbortError instead.

Common situations: Checkout pages kept open while the product is unpublished; browser currency (from navigator or geolocation) supplying an unexpected currency code; stale checkout bundles after a deploy changed the surcharge params; extensions stripping request bodies.

Related errors


AI-assisted analysis of antiwork/gumroad@afeacbd394 (2026-08-21). Data as JSON: /api/errors/05c4f6a28168ddec. Report an issue: GitHub.