{"record":{"id":"dc102f81163779a7","repo":"firecrawl/open-lovable","slug":"no-branding-data-in-firecrawl-response","errorCode":null,"errorMessage":"No branding data in Firecrawl response","messagePattern":"No branding data in Firecrawl response","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/api/extract-brand-styles/route.ts","lineNumber":49,"sourceCode":"      }),\n    });\n\n    if (!firecrawlResponse.ok) {\n      const errorText = await firecrawlResponse.text();\n      console.error('[extract-brand-styles] Firecrawl API error:', firecrawlResponse.status, errorText);\n      throw new Error(`Firecrawl API returned ${firecrawlResponse.status}`);\n    }\n\n    const firecrawlData = await firecrawlResponse.json();\n    console.log('[extract-brand-styles] Firecrawl response received successfully');\n\n    // Extract branding data from response\n    const brandingData = firecrawlData.data?.branding || firecrawlData.branding;\n\n    if (!brandingData) {\n      console.error('[extract-brand-styles] No branding data in Firecrawl response');\n      console.log('[extract-brand-styles] Response structure:', JSON.stringify(firecrawlData, null, 2));\n      throw new Error('No branding data in Firecrawl response');\n    }\n\n    console.log('[extract-brand-styles] Successfully extracted branding data');\n\n    // Return the branding data\n    return NextResponse.json({\n      success: true,\n      url,\n      styleName: brandingData.name || url,\n      guidelines: brandingData,\n    });\n\n  } catch (error) {\n    console.error('[extract-brand-styles] Error occurred:', error);\n    return NextResponse.json(\n      {\n        success: false,\n        error: error instanceof Error ? error.message : 'Failed to extract brand styles'","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/firecrawl/open-lovable/blob/69bd93bae7a9c97ef989eb70aabe6797fb3dac89/app/api/extract-brand-styles/route.ts#L31-L67","documentation":"Thrown when Firecrawl returns HTTP 200 but the parsed JSON contains no `data.branding` (or top-level `branding`) object — i.e. the scrape succeeded but branding extraction produced nothing, or the response shape differs from the expected v2 schema (e.g. wrong API version or formats not requested).","triggerScenarios":"POST /api/extract-brand-styles where the scraped site has no detectable branding (no logo, colors, fonts), the scrape returned only markdown/html because `formats` didn't include branding output, or the endpoint used returns a v1-shaped payload.","commonSituations":"Scraping SPAs or login-walled pages where content never renders; calling the v1 scrape endpoint instead of the branding-aware v2 endpoint; forgetting `formats: ['branding']`-style options in the request body.","solutions":["Inspect the server console log 'Response structure' to see the actual payload shape","Confirm the request targets https://api.firecrawl.dev/v2/scrape and requests branding extraction in the scrape options","Test with a branding-rich site (e.g. stripe.com) to rule out site-specific absence of branding data","Add a fallback/defaults object so the route degrades gracefully instead of throwing when branding is absent"],"exampleFix":"// before\nif (!brandingData) {\n  throw new Error('No branding data in Firecrawl response');\n}\n// after\nconst brandingData = firecrawlData.data?.branding || firecrawlData.branding || {\n  colors: { primary: '#000000' },\n  fonts: { body: 'system-ui' },\n  warning: 'No branding detected; using defaults'\n};","handlingStrategy":"fallback","validationCode":"const hasBranding = (d) => Boolean(d?.data?.branding || d?.branding);\nif (firecrawlData && !hasBranding(firecrawlData)) console.warn('Firecrawl returned no branding; defaults will be used');","typeGuard":"function hasBrandingData(d: any): d is { data?: { branding: object } } & { branding?: object } {\n  return Boolean(d?.data?.branding || d?.branding);\n}","tryCatchPattern":"try {\n  return await extractBrandStyles(url);\n} catch (e) {\n  if (e.message === 'No branding data in Firecrawl response') {\n    return DEFAULT_BRAND_STYLES; // degrade gracefully\n  }\n  throw e;\n}","preventionTips":["Call the v2 branding-aware endpoint with the correct scrape formats","Log the raw response structure whenever branding is absent to catch schema drift","Provide default brand styles so the product tolerates branding-less sites","Test against sites known to expose branding data"],"tags":["firecrawl","third-party-api","response-shape"],"backgroundTag":"unexpected-response-shape","analyzedSha":"69bd93bae7a9c97ef989eb70aabe6797fb3dac89","analyzedAt":"2026-08-28T22:20:32.339Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}