{"record":{"id":"e218ccca30ea299f","repo":"mastra-ai/mastra","slug":"failed-to-fetch-from-netlify-response-statustex","errorCode":null,"errorMessage":"Failed to fetch from Netlify: ${response.statusText}","messagePattern":"Failed to fetch from Netlify: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/llm/model/gateways/netlify.ts","lineNumber":45,"sourceCode":"  token: string;\n  url: string;\n  expiresAt: number;\n}\n\ninterface TokenData {\n  token: string;\n  url: string;\n}\n\nexport class NetlifyGateway extends MastraModelGateway {\n  readonly id = 'netlify';\n  readonly name = 'Netlify AI Gateway';\n  private tokenCache = new InMemoryServerCache();\n\n  async fetchProviders(): Promise<Record<string, ProviderConfig>> {\n    const response = await fetch('https://api.netlify.com/api/v1/ai-gateway/providers');\n    if (!response.ok) {\n      throw new Error(`Failed to fetch from Netlify: ${response.statusText}`);\n    }\n    const data = (await response.json()) as NetlifyResponse;\n    const config: ProviderConfig = {\n      apiKeyEnvVar: ['NETLIFY_TOKEN', 'NETLIFY_SITE_ID'],\n      apiKeyHeader: 'Authorization',\n      name: `Netlify`,\n      gateway: `netlify`,\n      models: [],\n      docUrl: 'https://docs.netlify.com/build/ai-gateway/overview/',\n    };\n    // Convert Netlify format to our standard format\n    for (const [providerId, provider] of Object.entries(data.providers)) {\n      for (const model of provider.models) {\n        config.models.push(`${providerId}/${model}`);\n      }\n    }\n    // Return with gateway ID as key - registry generator will detect this and avoid doubling the prefix\n    return { netlify: config };","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/llm/model/gateways/netlify.ts#L27-L63","documentation":"NetlifyGateway.fetchProviders() calls Netlify's public API (https://api.netlify.com/api/v1/ai-gateway/providers) to discover the AI Gateway provider/model catalog. If the HTTP response is not ok, it throws this error embedding response.statusText. This is a plain Error thrown during gateway registry population, before any model resolution.","triggerScenarios":"Any gateway registry refresh that includes the 'netlify' gateway when the Netlify providers endpoint returns a non-2xx status: network outage/DNS failure reaching api.netlify.com, Netlify API 5xx, rate limiting, TLS/proxy interception returning an error page, or a corporate firewall blocking the request.","commonSituations":"Running Mastra in an offline or air-gapped CI environment; behind a proxy that blocks api.netlify.com; transient Netlify API outage; aggressive polling triggering rate limits; Docker containers without external network access.","solutions":["Check network connectivity to https://api.netlify.com/api/v1/ai-gateway/providers (curl it) and retry — transient 5xx/429 often resolves on retry.","If behind a proxy/firewall, configure HTTPS_PROXY / NODE_EXTRA_CA_CERTS or allowlist api.netlify.com.","Deregister the netlify gateway (use only the gateways you need) if your environment can't reach Netlify and you don't use Netlify models.","Log response.status (not just statusText) and wrap the registry fetch with retry/backoff to tolerate transient failures."],"exampleFix":"// before\nconst gateways = [new ModelsDevGateway(), new NetlifyGateway()];\n// after (skip netlify when unreachable)\nconst gateways = process.env.NETLIFY_TOKEN\n  ? [new ModelsDevGateway(), new NetlifyGateway()]\n  : [new ModelsDevGateway()];","handlingStrategy":"retry","validationCode":"async function netlifyProvidersReachable() {\n  try {\n    const res = await fetch('https://api.netlify.com/api/v1/ai-gateway/providers');\n    return res.ok;\n  } catch {\n    return false;\n  }\n}\n// register NetlifyGateway only if netlifyProvidersReachable()","typeGuard":"function isOkResponse(res: Response): res is Response & { ok: true } {\n  return res.ok;\n}","tryCatchPattern":"try {\n  const providers = await netlifyGateway.fetchProviders();\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to fetch from Netlify')) {\n    console.warn('Netlify provider catalog unavailable; continuing without netlify gateway');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Wrap gateway registration in a reachability probe so offline/air-gapped environments skip netlify.","Add retry with exponential backoff around external catalog fetches.","Log response.status alongside statusText (statusText can be empty in fetch).","In CI, allowlist api.netlify.com or explicitly disable gateways you don't use."],"tags":["network","http","netlify","api-unavailable"],"backgroundTag":"http-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}