{"record":{"id":"11a467b8fe23785d","repo":"Stirling-Tools/Stirling-PDF","slug":"edge-function-name-failed","errorCode":null,"errorMessage":"Edge function ${name} failed","messagePattern":"Edge function (.+?) failed","errorType":"exception","errorClass":"StripeFunctionError","httpStatus":null,"severity":"error","filePath":"frontend/editor/src/portal/billing/stripe.ts","lineNumber":80,"sourceCode":"  url?: string;\n  error?: string;\n}\n\nasync function invoke<T>(\n  name: string,\n  body: Record<string, unknown>,\n): Promise<T> {\n  ensureSaasSupabase();\n  const supabase = getSupabaseClient();\n  if (!supabase) {\n    throw new StripeFunctionError(\n      \"SaaS Supabase not configured — set VITE_SUPABASE_URL.\",\n      \"unconfigured\",\n    );\n  }\n  const { data, error } = await supabase.functions.invoke<T>(name, { body });\n  if (error) {\n    throw new StripeFunctionError(\n      error.message ?? `Edge function ${name} failed`,\n    );\n  }\n  if (data == null) {\n    throw new StripeFunctionError(`Edge function ${name} returned no data`);\n  }\n  return data;\n}\n\n/** Call a SECURITY DEFINER public.* RPC with the admin's JWT (same client as {@link invoke}). */\nasync function rpc<T>(fn: string, args: Record<string, unknown>): Promise<T> {\n  ensureSaasSupabase();\n  const supabase = getSupabaseClient();\n  if (!supabase) {\n    throw new StripeFunctionError(\n      \"SaaS Supabase not configured — set VITE_SUPABASE_URL.\",\n      \"unconfigured\",\n    );","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/portal/billing/stripe.ts#L62-L98","documentation":"Fallback message in invoke() when supabase.functions.invoke returns an error whose .message is falsy. The edge function failed, but the error object carried no human-readable message, so the helper substitutes a generic description naming the failed function.","triggerScenarios":"An edge function invocation rejects with an error object that has no message property (or message === ''). This is the right-hand operand of `error.message ?? fallback`, so it only fires when message is null/undefined.","commonSituations":"Network/transport-level failures (CORS, DNS, aborted request) where the FunctionsError has a code but no message; a deployed edge function that throws a non-Error value; a Supabase client version that changed the error shape.","solutions":["Inspect the full StripeFunctionError in dev tools — the underlying FunctionsError often has a code/cause even when message is empty.","Check the edge function logs in the Supabase dashboard for the named function to see the real failure.","Verify network reachability + CORS for the function endpoint.","Upgrade @supabase/supabase-js consistently across the app to avoid error-shape drift."],"exampleFix":"// before\nthrow new StripeFunctionError(\n  error.message ?? `Edge function ${name} failed`,\n);\n\n// after — surface more of the underlying error for diagnosis\nthrow new StripeFunctionError(\n  error.message ?? `Edge function ${name} failed (${(error as any).code ?? \"no_code\"})`,\n  (error as { code?: string }).code,\n);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isFunctionsError(e: unknown): e is { message?: string; code?: string } {\n  return typeof e === \"object\" && e !== null && \"message\" in e;\n}","tryCatchPattern":"try {\n  return await invoke(\"create-checkout-session\", body);\n} catch (e) {\n  if (e instanceof StripeFunctionError) {\n    // message is the edge-function error or the generic fallback\n    notifications.show({ message: e.message, color: \"red\" });\n  }\n  throw e;\n}","preventionTips":["Always handle StripeFunctionError at the call site and surface e.message to the user.","Keep @supabase/supabase-js on a single pinned version across the app to avoid FunctionsError shape drift.","Monitor edge function logs so empty-message errors are diagnosed server-side."],"tags":["billing","stripe","supabase","edge-function","network"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}